Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorArt Cancro <ajc@uncensored.citadel.org>
Thu, 23 Feb 2012 16:32:23 +0000 (11:32 -0500)
committerArt Cancro <ajc@uncensored.citadel.org>
Thu, 23 Feb 2012 16:32:23 +0000 (11:32 -0500)
ctdlsh/README
ctdlsh/src/ctdlsh.h
ctdlsh/src/datetime.c
ctdlsh/src/main.c
ctdlsh/src/passwd.c
ctdlsh/src/shutdown.c
ctdlsh/src/sockets.c

index 38b234e6c181f1fc44fcaa6fd47bf39c4ceea63e..35143f9312bf05e8febb8c9977c6694e8469b046 100644 (file)
@@ -5,3 +5,6 @@ submit patches, but if you attempt to use it in a production system or
 if you request support for the program, you will be told to die in a
 car fire.
 
+This is open source software.  It runs really well on the Linux operating
+system.  We reject Richard Stallman's linguistic fascism and so should you.
+
index caf4b516ec52d6e6900eaafdc40e11ef84944619..77ca9e7e9db5699c488d7d9a3f6e33442a544fad 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * main header file for ctdlsh
+ *
+ * Copyright (c) 2009-2012 by the citadel.org team
+ * This program is open source software, cheerfully made available to
+ * you under the terms of the GNU General Public License version 3.
+ */
+
 #include <config.h>
 #include <stdlib.h>
 #include <unistd.h>
  */
 #define CTDLDIR        "/appl/citadel"
 
-/*
- * This is a small subset of 'struct config' ... don't worry about the rest; we
- * only need to snarf the c_ipgm_secret.
- */
-struct partial_config {
-       char c_nodename[16];            /* Unqualified "short" nodename     */
-       char c_fqdn[64];                /* Fully Qualified Domain Name      */
-       char c_humannode[21];           /* Long name of system              */
-       char c_phonenum[16];            /* Dialup number of system          */
-       uid_t c_ctdluid;                /* UID under which we run Citadel   */
-       char c_creataide;               /* room creator = room aide  flag   */
-       int c_sleeping;                 /* watchdog timer setting           */
-       char c_initax;                  /* initial access level             */
-       char c_regiscall;               /* call number to register on       */
-       char c_twitdetect;              /* twit detect flag                 */
-       char c_twitroom[128];           /* twit detect msg move to room     */
-       char c_moreprompt[80];          /* paginator prompt                 */
-       char c_restrict;                /* restrict Internet mail flag      */
-       long c_niu_1;                   /* (not in use)                     */
-       char c_site_location[32];       /* physical location of server      */
-       char c_sysadm[26];              /* name of system administrator     */
-       char c_niu_2[15];               /* (not in use)                     */
-       int c_setup_level;              /* what rev level we've setup to    */
-       int c_maxsessions;              /* maximum concurrent sessions      */
-       char c_ip_addr[20];             /* IP address to listen on          */
-       int c_port_number;              /* Cit listener port (usually 504)  */
-       int c_ipgm_secret;              /* Internal program authentication  */
-};
-
 typedef int ctdlsh_cmdfunc_t(int, char *);
 
 enum ctdlsh_cmdfunc_return_values {
index 122b98f7fd0c45a6edc8d5021a72b0d835ce067a..38a4456a2ebebb5527b1ff6e871fa93fde1d6c4d 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * (c) 2009-2011 by Art Cancro and citadel.org
- * This program is released under the terms of the GNU General Public License v3.
+ * This program is open source software, released under the terms of the GNU General Public License v3.
+ * It runs really well on the Linux operating system.
+ * We love open source software but reject Richard Stallman's linguistic fascism.
  */
 
 #include "ctdlsh.h"
index 1b16be3f0248b0e2f9e8e0d6da206f5aa5129c54..f996e68ec756e2c4b55e16b43fdfa6737818623e 100644 (file)
@@ -1,13 +1,11 @@
 /*
- * (c) 2009-2011 by Art Cancro and citadel.org
+ * (c) 2009-2012 by Art Cancro and citadel.org
  * This program is released under the terms of the GNU General Public License v3.
  */
 
 #include "ctdlsh.h"
 
 
-
-
 int cmd_quit(int sock, char *cmdbuf) {
        return(cmdret_exit);
 }
@@ -44,34 +42,6 @@ int cmd_help(int sock, char *cmdbuf) {
 }
 
 
-
-
-
-
-int discover_ipgm_secret(char *dirname) {
-       int fd;
-       struct partial_config ccc;
-       char configfile[1024];
-
-       sprintf(configfile, "%s/citadel.config", dirname);
-       fd = open(configfile, O_RDONLY);
-       if (fd < 0) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-
-       if (read(fd, &ccc, sizeof(struct partial_config)) != sizeof(struct partial_config)) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-       if (close(fd) != 0) {
-               fprintf(stderr, "%s: %s\n", configfile, strerror(errno));
-               return(-1);
-       }
-       return(ccc.c_ipgm_secret);
-}
-
-
 /* Auto-completer function */
 char *command_generator(const char *text, int state) {
        static int list_index;
@@ -110,7 +80,6 @@ char **ctdlsh_completion(const char *text, int start, int end) {
 }
 
 
-
 void do_main_loop(int server_socket) {
        char *cmd = NULL;
        char prompt[1024];
@@ -155,16 +124,21 @@ void do_main_loop(int server_socket) {
        }
 }
 
+
+/*
+ * If you don't know what main() does by now you probably shouldn't be reading this code.
+ */
 int main(int argc, char **argv)
 {
        int server_socket = 0;
        char buf[1024];
-       int ipgm_secret = (-1);
        int c;
        char *ctdldir = CTDLDIR;
 
-       printf("\nCitadel administration shell v" PACKAGE_VERSION "\n");
-       printf("(c) 2009-2011 citadel.org GPLv3\n");
+       printf("\nCitadel administration shell v" PACKAGE_VERSION " (c) 2009-2012 by citadel.org\n"
+               "This is open source software made available to you under the terms\n"
+               "of the GNU General Public License v3.  All other rights reserved.\n"
+       );
 
        opterr = 0;
        while ((c = getopt (argc, argv, "h:")) != -1) {
@@ -184,25 +158,14 @@ int main(int argc, char **argv)
                }
        }
 
-       ipgm_secret = discover_ipgm_secret(ctdldir);
-       if (ipgm_secret < 0) {
-               exit(1);
-       }
-
        printf("Trying %s...\n", ctdldir);
-       sprintf(buf, "%s/citadel.socket", ctdldir);
+       sprintf(buf, "%s/citadel-admin.socket", ctdldir);
        server_socket = uds_connectsock(buf);
        if (server_socket < 0) {
                exit(1);
        }
 
        sock_getln(server_socket, buf, sizeof buf);
-       printf("%s\n", buf);
-
-       sock_printf(server_socket, "IPGM %d\n", ipgm_secret);
-       sock_getln(server_socket, buf, sizeof buf);
-       printf("%s\n", buf);
-
        if (buf[0] == '2') {
                do_main_loop(server_socket);
        }
index 65ae280e9097662c38f38cc321219a3eae14204d..2b914abb205062d5ad8b420dfdfe265aba7b8f0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (c) 2009-2011 by Art Cancro and citadel.org
+ * (c) 2009-2012 by Art Cancro and citadel.org
  * This program is released under the terms of the GNU General Public License v3.
  */
 
@@ -13,6 +13,9 @@ int cmd_passwd(int server_socket, char *cmdbuf) {
        char *p2;
 
        strcpy(account_name, &cmdbuf[7]);
+       if (strlen(account_name) == 0) {
+               strncpy(account_name, readline("Enter account name: "), sizeof account_name);
+       }
        sock_printf(server_socket, "AGUP %s\n", account_name);
        sock_getln(server_socket, buf, sizeof buf);
        if (buf[0] != '2') {
@@ -24,7 +27,9 @@ int cmd_passwd(int server_socket, char *cmdbuf) {
        p2 = readline("Enter it again: ");
 
        if (strcmp(p1, p2)) {
-               fprintf(stderr, "Passwords do not match.  Account password is unchanged.\n");
+               fprintf(stderr, "The passwords you entered do not match."
+                               "The account password remains unchanged.\n"
+               );
                return(cmdret_error);
        }
 
index cab803604c1883bf5772a743389afe031c58e13a..a3c253f16949298fc0e132e1f2f090cf6182eaaa 100644 (file)
@@ -24,7 +24,3 @@ int cmd_shutdown(int server_socket, char *cmdbuf) {
        fprintf(stderr, "%s\n", &buf[4]);
        return(cmdret_ok);
 }
-
-
-
-
index 0d914b6ab4f52f3ea0f1004d158d3f1ed558b04c..3aaf7714064666dd55c79edf46462ffd2a5029e2 100644 (file)
@@ -1,12 +1,14 @@
 /*
- *
+ * This file contains functions which handle ctdlsh's connection
+ * to the Citadel server's admin socket.  
+ * 
+ * Copyright (c) 2009-2012 by the Citadel.org team.
+ * This program is open source software, cheerfully made available to you under
+ * the terms of the GNU General Public License version 3.
  */
 
 #include "ctdlsh.h"
 
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
 
 int uds_connectsock(char *sockpath)
 {
@@ -102,7 +104,6 @@ int sock_write(int sock, char *buf, int nbytes)
 }
 
 
-
 /*
  * Input string from socket - implemented in terms of sock_read()
  * 
@@ -138,9 +139,8 @@ int sock_getln(int sock, char *buf, int bufsize)
 }
 
 
-
 /*
- * sock_puts() - send line to server - implemented in terms of serv_write()
+ * sock_puts() - send line to server - implemented in terms of sock_write()
  * Returns the number of bytes written, or -1 for error.
  */
 int sock_puts(int sock, char *buf)
@@ -155,6 +155,9 @@ int sock_puts(int sock, char *buf)
 }
 
 
+/*
+ * Write a formatted string to the server - implemented in terms of sock_write()
+ */
 void sock_printf(int sock, const char *format,...)
 {
        va_list arg_ptr;