X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/65e83e097c8635856816a07bab5e330a6615dfc1..9e7acc86c3a777f65b32d495b7e37e86882f93c8:/popt/popt.c diff --git a/popt/popt.c b/popt/popt.c index 756ddfee..a01b6b96 100644 --- a/popt/popt.c +++ b/popt/popt.c @@ -392,7 +392,6 @@ static int execCommand(poptContext con) poptItem item = con->doExec; const char ** argv; int argc = 0; - int rc; if (item == NULL) /*XXX can't happen*/ return POPT_ERROR_NOARG; @@ -432,8 +431,9 @@ static int execCommand(poptContext con) argv[argc] = NULL; + { #ifdef __hpux - rc = setresgid(getgid(), getgid(),-1); + int rc = setresgid(getgid(), getgid(),-1); if (rc) return POPT_ERROR_ERRNO; rc = setresuid(getuid(), getuid(),-1); if (rc) return POPT_ERROR_ERRNO; @@ -444,12 +444,12 @@ static int execCommand(poptContext con) * XXX from Norbert Warmuth */ #if defined(HAVE_SETUID) - rc = setgid(getgid()); + int rc = setgid(getgid()); if (rc) return POPT_ERROR_ERRNO; rc = setuid(getuid()); if (rc) return POPT_ERROR_ERRNO; #elif defined (HAVE_SETREUID) - rc = setregid(getgid(), getgid()); + int rc = setregid(getgid(), getgid()); if (rc) return POPT_ERROR_ERRNO; rc = setreuid(getuid(), getuid()); if (rc) return POPT_ERROR_ERRNO; @@ -457,6 +457,7 @@ static int execCommand(poptContext con) ; /* Can't drop privileges */ #endif #endif + } if (argv[0] == NULL) return POPT_ERROR_NOARG; @@ -808,16 +809,20 @@ int poptGetNextOpt(poptContext con) *oe++ = '\0'; /* XXX longArg is mapped back to persistent storage. */ longArg = origOptString + (oe - localOptString); - } + } else + oe = NULL; opt = findOption(con->options, optString, '\0', &cb, &cbData, singleDash); if (!opt && !singleDash) return POPT_ERROR_BADOPT; + if (!opt && oe) + oe[-1] = '='; /* restore overwritten '=' */ } if (!opt) { con->os->nextCharArg = origOptString + 1; + longArg = NULL; } else { if (con->os == con->optionStack && opt->argInfo & POPT_ARGFLAG_STRIP) @@ -855,7 +860,7 @@ int poptGetNextOpt(poptContext con) origOptString++; if (*origOptString != '\0') - con->os->nextCharArg = origOptString; + con->os->nextCharArg = origOptString + (*origOptString == '='); } /*@=branchstate@*/