OSSP CVS Repository

ossp - Check-in [1753]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1753
Date: 2002-Jan-31 16:42:31 (local)
2002-Jan-31 15:42:31 (UTC)
User:thl
Branch:
Comment: moved --user option
Tickets:
Inspections:
Files:
ossp-pkg/lmtp2nntp/example.conf      1.12 -> 1.13     1 inserted, 1 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_config.c      1.32 -> 1.33     27 inserted, 0 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_main.c      1.25 -> 1.26     0 inserted, 17 deleted
ossp-pkg/lmtp2nntp/lmtp2nntp_option.c      1.6 -> 1.7     1 inserted, 1 deleted

ossp-pkg/lmtp2nntp/example.conf 1.12 -> 1.13

--- example.conf 2002/01/31 15:32:51     1.12
+++ example.conf 2002/01/31 15:42:31     1.13
@@ -49,7 +49,7 @@
 timeoutnntpconnect 360                          #see        --timeoutnntpconnect
 timeoutnntpread    60                           #see        --timeoutnntpread
 timeoutnntpwrite   60                           #see        --timeoutnntpwrite
-uid             gate                            #see -u aka --uid
+user            gate                            #see -u aka --user
                                                 #    -v aka --version is not available in the configfile
 newsgroup       "test"
 newsgroup       "alt.test"                      #see man page for information about newsgroup


ossp-pkg/lmtp2nntp/lmtp2nntp_config.c 1.32 -> 1.33

--- lmtp2nntp_config.c   2002/01/31 15:32:51     1.32
+++ lmtp2nntp_config.c   2002/01/31 15:42:31     1.33
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <errno.h>
+#include <pwd.h>
 
 /* third party (included) */
 #include "lmtp2nntp_argz.h"
@@ -747,6 +748,32 @@
     catch (ex)
         rethrow;
 
+    /* --user SINGLE */
+    try {
+        struct passwd *sPasswd;
+
+        if (   (val_get(ctx->val, "option.user", &ov) != VAL_OK)
+            || (ov->ndata != 1)
+            || (ov->data.s == NULL)
+              ) throw(0,0,0);
+        log1(ctx, TRACE, "--user = \"%s\"", ov->data.s);
+
+        if (isdigit((int)ov->data.s[0])) {
+            if ((sPasswd = getpwuid((uid_t)atoi(ov->data.s))) == NULL) {
+                log1(ctx, ERROR, "option --user, uid (%s) not found", ov->data.s);
+                throw(0,0,0);
+            }
+        }
+        else {
+            if ((sPasswd = getpwnam(optarg)) == NULL) {
+                log1(ctx, ERROR, "option --user, name (%s) not found", ov->data.s);
+                throw(0,0,0);
+            }
+        }
+        ctx->option_uid = sPasswd->pw_uid;
+    }
+    catch (ex)
+        rethrow;
 CUS:
     return;
 }


ossp-pkg/lmtp2nntp/lmtp2nntp_main.c 1.25 -> 1.26

--- lmtp2nntp_main.c     2002/01/31 15:32:51     1.25
+++ lmtp2nntp_main.c     2002/01/31 15:42:31     1.26
@@ -36,7 +36,6 @@
 #include <sys/wait.h>
 #include <sys/stat.h>
 #include <signal.h>
-#include <pwd.h>
 
 /* third party (included) */
 #include "lmtp2nntp_argz.h"
@@ -357,7 +356,6 @@
     int           i;             /* general purpose scratch int, index ... */
     pid_t         pid;
     FILE         *fd;
-    struct passwd *sPasswd;
 
     /* drop effective uid/gid priviledges */
     seteuid(getuid());
@@ -444,21 +442,6 @@
     /* read in the arguments */
     while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:r:s:t:u:v")) != -1) {
         switch (i) {
-            case 'u': /*POD [B<-u> I<uid>] */
-                if (isdigit((int)optarg[0])) {
-                    if ((sPasswd = getpwuid((uid_t)atoi(optarg))) == NULL) {
-                        fprintf(stderr, "%s:Error: uid \"%s\" not found for -u option.\n", ctx->progname, optarg);
-                        CU(ERR_EXECUTION);
-                    }
-                }
-                else {
-                    if ((sPasswd = getpwnam(optarg)) == NULL) {
-                        fprintf(stderr, "%s:Error: loginname \"%s\" not found for -u option.\n", ctx->progname, optarg);
-                        CU(ERR_EXECUTION);
-                    }
-                }
-                ctx->option_uid = sPasswd->pw_uid;
-                break;
             case 'v': /*POD [B<-v>] (version)*/
                 fprintf(stdout, "%s\n", lmtp2nntp_version.v_gnu);
                 CU(0);


ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.6 -> 1.7

--- lmtp2nntp_option.c   2002/01/31 15:32:51     1.6
+++ lmtp2nntp_option.c   2002/01/31 15:42:31     1.7
@@ -626,7 +626,7 @@
     (void)option_register(o, "nodename",           'n', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo21", "nodename" );
     (void)option_register(o, "operationmode",      'o', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo22", "post|feed" );
     (void)option_register(o, "l2spec",             'l', OPT_SINGLE, &stdsyntax, "m/.*/",     "L2 channel tree textual specification", "l2spec" );
-    (void)option_register(o, "uid",                'u', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo24", "number|name" );
+    (void)option_register(o, "user",               'u', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo24", "uid|name" );
     (void)option_register(o, "restrictheader",     'r', OPT_SINGLE, &stdsyntax, "m/.*/",     "foo25", "regex" );
     (void)option_register(o, "newsgroup",          NUL, OPT_MULTI,  &stdsyntax, "m/.*/",     "foo26", "newsgroup");
 

CVSTrac 2.0.1