Ticket #39: setproctitle-solaris.patch

File setproctitle-solaris.patch, 6.3 KB (added by eagle, 14 years ago)

Patch against STABLE 20051208

  • frontends/ovdb_init.c

    diff -ru inn-STABLE-20051208-orig/frontends/ovdb_init.c inn-STABLE-20051208/frontends/ovdb_init.c
    old new  
    455455        case 0:
    456456            setsid();
    457457            execl(concatpath(innconf->pathbin, "ovdb_monitor"),
    458                 "ovdb_monitor", SPACES, NULL);
     458                OVDB_M, NULL);
    459459            syswarn("cannot exec ovdb_monitor");
    460460            _exit(1);
    461461        }
     
    472472            case 0:
    473473                setsid();
    474474                execl(concatpath(innconf->pathbin, "ovdb_server"),
    475                     "ovdb_server", SPACES, NULL);
     475                    OVDB_S, NULL);
    476476                syswarn("cannot exec ovdb_server");
    477477                _exit(1);
    478478            }
  • frontends/ovdb_monitor.c

    diff -ru inn-STABLE-20051208-orig/frontends/ovdb_monitor.c inn-STABLE-20051208/frontends/ovdb_monitor.c
    old new  
    283283}
    284284
    285285
    286 int main(int argc, char **argv)
     286int main(int argc, char *argv[], char *envp[])
    287287{
    288288    char *pidfile;
    289289
    290     setproctitle_init(argc, argv);
     290    setproctitle_init(argc, argv, envp);
    291291
    292292    openlog("ovdb_monitor", L_OPENLOG_FLAGS | LOG_PID, LOG_INN_PROG);
    293293    message_program_name = "ovdb_monitor";
    294294
    295     if(argc != 2 || strcmp(argv[1], SPACES))
     295    if(argc != 1 || strcmp(argv[0], OVDB_M))
    296296        die("should be started by ovdb_init");
    297297    message_handlers_warn(1, message_log_syslog_err);
    298298    message_handlers_die(1, message_log_syslog_err);
  • frontends/ovdb_server.c

    diff -ru inn-STABLE-20051208-orig/frontends/ovdb_server.c inn-STABLE-20051208/frontends/ovdb_server.c
    old new  
    607607}
    608608
    609609int
    610 main(int argc, char *argv[])
     610main(int argc, char *argv[], char *envp[])
    611611{
    612612    int i, ret;
    613613    socklen_t salen;
     
    620620    struct timeval tv;
    621621    fd_set rdset;
    622622
    623     setproctitle_init(argc, argv);
     623    setproctitle_init(argc, argv, envp);
    624624
    625625    openlog("ovdb_server", L_OPENLOG_FLAGS | LOG_PID, LOG_INN_PROG);
    626626    message_program_name = "ovdb_server";
    627627
    628     if(argc != 2 || strcmp(argv[1], SPACES))
     628    if(argc != 1 || strcmp(argv[0], OVDB_S))
    629629        die("should be started by ovdb_init");
    630630    message_handlers_warn(1, message_log_syslog_err);
    631631    message_handlers_die(1, message_log_syslog_err);
  • include/portable/setproctitle.h

    diff -ru inn-STABLE-20051208-orig/include/portable/setproctitle.h inn-STABLE-20051208/include/portable/setproctitle.h
    old new  
    1717#endif
    1818
    1919#if HAVE_SETPROCTITLE || HAVE_PSTAT
    20 # define setproctitle_init(argc, argv)   /* empty */
     20# define setproctitle_init(argc, argv, envp)   /* empty */
    2121#else
    22 void setproctitle_init(int argc, char *argv[]);
     22void setproctitle_init(int argc, char *argv[], char *envp[]);
    2323#endif
    2424
    2525#endif /* !PORTABLE_SETPROCTITLE_H */
  • innd/rc.c

    diff -ru inn-STABLE-20051208-orig/innd/rc.c inn-STABLE-20051208/innd/rc.c
    old new  
    448448void
    449449RChandoff(int fd, HANDOFF h)
    450450{
    451     const char *argv[6];
     451    const char *argv[5];
    452452    char buff[SMBUF];
    453453    int i;
    454454
     
    472472    case HOnnrpd:       argv[0] = RCnnrpd;      break;
    473473    case HOnntpd:       argv[0] = RCnntpd;      break;
    474474    }
    475     argv[1] = "-s                                                ";
    476     i = 2;
     475    i = 1;
    477476    if (NNRPReason) {
    478477        snprintf(buff, sizeof(buff), "-r%s", NNRPReason);
    479478        argv[i++] = buff;
  • lib/setproctitle.c

    diff -ru inn-STABLE-20051208-orig/lib/setproctitle.c inn-STABLE-20051208/lib/setproctitle.c
    old new  
    4747
    4848static char *title_start = NULL;
    4949static char *title_end = NULL;
     50static char **xargv = NULL;
    5051
    5152void
    52 setproctitle_init(int argc, char *argv[])
     53setproctitle_init(int argc, char *argv[], char *envp[])
    5354{
     55    int i;
     56    char **xenv;
     57    extern char **environ;
     58
    5459    title_start = argv[0];
    5560    title_end = argv[argc - 1] + strlen(argv[argc - 1]) - 1;
     61
     62    xargv = argv;
     63    if (!envp)
     64        return;
     65
     66    if (environ) {
     67        for (i=0; environ[i]; i++)
     68            ;
     69        xenv = malloc((i+1) * sizeof(char*));
     70        if (!xenv)
     71            return;
     72        for (i=0; environ[i]; i++) {
     73            xenv[i] = strdup(environ[i]);
     74            if (!xenv[i]) {
     75                for (i--; i >= 0; i--)
     76                    free(xenv[i]);
     77                free(xenv);
     78                return;
     79            }
     80        }
     81        xenv[i] = NULL;
     82        environ = xenv;
     83    }
     84
     85    for (i=0; envp[i]; i++)
     86        title_end += strlen(envp[i]) + 1;
     87
    5688}
    5789
    5890void
     
    68100        return;
    69101    }
    70102
     103    xargv[1] = NULL;
     104
    71105    /* setproctitle prepends the program name to its arguments.  Our emulation
    72106       should therefore do the same thing.  However, some operating systems
    73107       seem to do that automatically even when we completely overwrite argv,
  • nnrpd/nnrpd.c

    diff -ru inn-STABLE-20051208-orig/nnrpd/nnrpd.c inn-STABLE-20051208/nnrpd/nnrpd.c
    old new  
    783783
    784784/* ARGSUSED0 */
    785785int
    786 main(int argc, char *argv[])
     786main(int argc, char *argv[], char *envp[])
    787787{
    788788    const char *name;
    789789    CMDENT              *cp;
     
    829829
    830830    int respawn = 0;
    831831
    832     setproctitle_init(argc, argv);
     832    setproctitle_init(argc, argv, envp);
    833833
    834834    /* Parse arguments.   Must xstrdup() optarg if used because setproctitle may
    835835       clobber it! */
  • storage/ovdb/ovdb-private.h

    diff -ru inn-STABLE-20051208-orig/storage/ovdb/ovdb-private.h inn-STABLE-20051208/storage/ovdb/ovdb-private.h
    old new  
    112112#define OVDB_LOCKFN "ovdb.sem"
    113113#define OVDB_MONITOR_PIDFILE "ovdb_monitor.pid"
    114114#define OVDB_SERVER_PIDFILE "ovdb_server.pid"
    115 #define SPACES "                "
     115#define OVDB_M "ovdb_monitor "
     116#define OVDB_S "ovdb_server "
    116117
    117118/* read server stuff */
    118119#define CMD_QUIT        0x01