Przeglądaj źródła

* More cmd_conf work

svn: 975
Bryan Drewery 22 lat temu
rodzic
commit
7de570e2a9
4 zmienionych plików z 53 dodań i 33 usunięć
  1. 49 1
      src/cmds.c
  2. 1 30
      src/conf.c
  3. 2 1
      src/conf.h
  4. 1 1
      src/mod/share.mod/share.c

+ 49 - 1
src/cmds.c

@@ -1843,6 +1843,7 @@ static void cmd_sha1(struct userrec *u, int idx, char *par)
 static void cmd_conf(struct userrec *u, int idx, char *par)
 {
   char *cmd = NULL;
+  int save = 0;
 
   if (!localhub) {
     dprintf(idx, "Please use '%s%s%s' for this login/shell.\n", RED(idx), conf.localhub, COLOR_END(idx));
@@ -1875,7 +1876,54 @@ static void cmd_conf(struct userrec *u, int idx, char *par)
                     bot->host6 ? bot->host6 : "",
                     bot->pid);
     }
+#ifndef CYGWIN_HACKS
+  } else if (!egg_strcasecmp(cmd, "set")) {
+    char *what = NULL;
+    int show = 1, set = 0;
+
+    if (par[0]) {       
+      what = newsplit(&par);
+
+      if (par[0] && what) { /* set */
+        set++;
+        save = 1;
+//        if (!egg_strcasecmp(what, "uid"))            conffile.uid = atoi(par);
+//        else if (!egg_strcasecmp(what, "uname"))     str_redup(&conffile.uname, par);
+//        else if (!egg_strcasecmp(what, "username"))  str_redup(&conffile.username, par);
+        if (!egg_strcasecmp(what, "homedir"))   str_redup(&conffile.homedir, par);
+        else if (!egg_strcasecmp(what, "binpath"))   str_redup(&conffile.binpath, par);
+        else if (!egg_strcasecmp(what, "binname"))   str_redup(&conffile.binname, par);
+        else if (!egg_strcasecmp(what, "portmin"))   conffile.portmin = atoi(par);
+        else if (!egg_strcasecmp(what, "portmax"))   conffile.portmax = atoi(par);
+        else if (!egg_strcasecmp(what, "pscloak"))   conffile.pscloak = atoi(par);
+        else if (!egg_strcasecmp(what, "autocron"))  conffile.autocron = atoi(par);
+        else if (!egg_strcasecmp(what, "autouname")) conffile.autouname = atoi(par);
+        else { 
+          set--;
+          save = 0;
+          dprintf(idx, "Unknown option '%s'\n", par);
+        }
+      }
+    }
+    if (show) {
+      char *ss = set ? "Set: " : "";
+      
+//      if (!what || !egg_strcasecmp(what, "uid"))        dprintf(idx, "%suid: %d\n", ss, conffile.uid);
+//      if (!what || !egg_strcasecmp(what, "uname"))      dprintf(idx, "%suname: %s\n", ss, conffile.uname);
+//      if (!what || !egg_strcasecmp(what, "username"))   dprintf(idx, "%susername: %s\n", ss, conffile.username);
+      if (!what || !egg_strcasecmp(what, "homedir"))    dprintf(idx, "%shomedir: %s\n", ss, conffile.homedir);
+      if (!what || !egg_strcasecmp(what, "binpath"))    dprintf(idx, "%sbinpath: %s\n", ss, conffile.binpath);
+      if (!what || !egg_strcasecmp(what, "binname"))    dprintf(idx, "%sbinname: %s\n", ss, conffile.binname);
+      if (!what || !egg_strcasecmp(what, "portmin"))    dprintf(idx, "%sportmin: %d\n", ss, conffile.portmin);
+      if (!what || !egg_strcasecmp(what, "portmax"))    dprintf(idx, "%sportmax: %d\n", ss, conffile.portmax);
+      if (!what || !egg_strcasecmp(what, "pscloak"))    dprintf(idx, "%spsclaok: %d\n", ss, conffile.pscloak);
+      if (!what || !egg_strcasecmp(what, "autocron"))   dprintf(idx, "%sautocron: %d\n", ss, conffile.autocron);
+      if (!what || !egg_strcasecmp(what, "autouname"))  dprintf(idx, "%sautouname: %d\n", ss, conffile.autouname);
+    }
+#endif /* !CYGWIN_HACKS */
   }
+  if (save)
+    writeconf(cfile, NULL, CONF_ENC);
   /* showconf(idx); */
 }
 
@@ -3136,7 +3184,7 @@ static void cmd_nopass(struct userrec *u, int idx, char *par)
   struct userrec *cu = NULL;
   char *users = NULL;
 
-  users = malloc(1);
+  users = calloc(1, 1);
 
   putlog(LOG_CMDS, "*", "#%s# nopass %s", dcc[idx].nick, (par && par[0]) ? par : "");
 

+ 1 - 30
src/conf.c

@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <signal.h>
 
+char cfile[DIRMAX] = "";
 conf_t conf;                    /* global conf struct */
 conf_t conffile;                /* just some config options only avail during loading */
 
@@ -94,7 +95,6 @@ swap_uids_back()
   return (setegid(save_egid) || seteuid(save_euid)) ? -1 : 0;
 }
 
-
 void
 confedit(char *cfile)
 {
@@ -349,35 +349,6 @@ conf_addbot(char *nick, char *ip, char *host, char *ip6)
   bot->pid = checkpid(nick, bot);
 }
 
-
-void
-showconf(int idx)
-{
-  conf_bot *bot = NULL;
-
-#ifndef CYGWIN_HACKS
-  dprintf(idx, "uid      : %d\n", conffile.uid);
-  dprintf(idx, "uname    : %s\n", conffile.uname);
-  dprintf(idx, "username : %s\n", conffile.username);
-  dprintf(idx, "homedir  : %s\n", conffile.homedir);
-  dprintf(idx, "binpath  : %s\n", conffile.binpath);
-  dprintf(idx, "binname  : %s\n", conffile.binname);
-  dprintf(idx, "portmin  : %d\n", conffile.portmin);
-  dprintf(idx, "portmax  : %d\n", conffile.portmax);
-  dprintf(idx, "pscloak  : %d\n", conffile.pscloak);
-  dprintf(idx, "autocron : %d\n", conffile.autocron);
-  dprintf(idx, "autouname: %d\n", conffile.autouname);
-#endif /* !CYGWIN_HACKS */
-  for (bot = conffile.bots; bot && bot->nick; bot = bot->next)
-    dprintf(idx, "%s IP: %s HOST: %s IP6: %s HOST6: %s PID: %d\n",
-             bot->nick, 
-             bot->ip ? bot->ip : "",
-             bot->host ? bot->host : "",
-             bot->ip6 ? bot->ip6 : "", 
-             bot->host6 ? bot->host6 : "", 
-             bot->pid);
-}
-
 void
 free_conf()
 {

+ 2 - 1
src/conf.h

@@ -4,6 +4,7 @@
 #include <sys/types.h>
 #include <stdio.h>
 #include "types.h"
+#include "eggdrop.h"
 
 
 typedef struct conf_bot_b {
@@ -55,7 +56,6 @@ int killbot(char *);
 void confedit(char *);
 #endif /* S_CONFEDIT */
 pid_t checkpid(char *, conf_bot *);
-void showconf(int);
 void init_conf();
 void free_conf();
 int readconf(char *, int);
@@ -63,4 +63,5 @@ int parseconf();
 int writeconf(char *, FILE *, int);
 void fillconf(conf_t *);
 
+extern char		cfile[DIRMAX];
 #endif /* !_CONF_H */

+ 1 - 1
src/mod/share.mod/share.c

@@ -281,7 +281,7 @@ share_chattr(int idx, char *par)
           noshare = 0;
           build_flags(s, &fr, 0);
           if (!(dcc[idx].status & STAT_GETTING))
-            putlog(LOG_CMDS, "*", "%s: chattr %s %s %s", dcc[idx].nick, hand, s, par);
+            putlog(LOG_CMDS, "@", "%s: chattr %s %s %s", dcc[idx].nick, hand, s, par);
 #ifdef LEAF
           recheck_channel(cst, 0);
 #endif /* LEAF */