setproctitle() doesn't need to be called with root privs, so move

it from id.c into defs.c
This commit is contained in:
Brian Somers 2000-08-16 09:07:23 +00:00
parent 2ceee5e9a7
commit ebe96675ee
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64698
6 changed files with 20 additions and 28 deletions

View File

@ -51,7 +51,6 @@
#include <sys/uio.h>
#include <sys/wait.h>
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
#include <sys/linker.h>
#include <sys/module.h>
#endif
#include <termios.h>
@ -1852,7 +1851,7 @@ bundle_setsid(struct bundle *bundle, int holdsession)
*/
waitpid(pid, &status, 0);
/* Tweak our process arguments.... */
ID0setproctitle("session owner");
SetTitle("session owner");
setuid(ID0realuid());
/*
* Hang around for a HUP. This should happen as soon as the

View File

@ -33,11 +33,6 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@ -2731,7 +2726,7 @@ SetProcTitle(struct cmdargs const *arg)
int len, remaining, f, argc = arg->argc - arg->argn;
if (arg->argc == arg->argn) {
ID0setproctitle(NULL);
SetTitle(NULL);
return 0;
}
@ -2757,7 +2752,7 @@ SetProcTitle(struct cmdargs const *arg)
}
*ptr = '\0';
ID0setproctitle(title);
SetTitle(title);
return 0;
}

View File

@ -35,6 +35,11 @@
#include <ctype.h>
#include <errno.h>
#ifdef __OpenBSD__
#include <util.h>
#else
#include <libutil.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -358,3 +363,14 @@ ex_desc(int ex)
snprintf(num, sizeof num, "%d", ex);
return num;
}
void
SetTitle(const char *title)
{
if (title == NULL)
setproctitle(NULL);
else if (title[0] == '-' && title[1] != '\0')
setproctitle("-%s", title + 1);
else
setproctitle("%s", title);
}

View File

@ -114,3 +114,4 @@ extern int MakeArgs(char *, char **, int, int);
extern const char *NumStr(long, char *, size_t);
extern const char *HexStr(long, char *, size_t);
extern const char *ex_desc(int);
extern void SetTitle(const char *);

View File

@ -38,7 +38,6 @@
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> /* setproctitle() under OpenBSD (+NetBSD ?)*/
#include <string.h>
#include <sysexits.h>
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
@ -273,23 +272,6 @@ ID0kill(pid_t pid, int sig)
return result;
}
void
ID0setproctitle(const char *title)
{
ID0set0();
if (title == NULL) {
setproctitle(NULL);
log_Printf(LogID0, "setproctitle(NULL)\n");
} else {
if (title[0] == '-' && title[1] != '\0')
setproctitle("-%s", title + 1);
else
setproctitle("%s", title);
log_Printf(LogID0, "setproctitle(\"%%s\", \"%s\")\n", title);
}
ID0setuser();
}
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
int
ID0kldload(const char *dev)

View File

@ -45,7 +45,6 @@ extern void ID0logout(const char *, int);
extern int ID0bind_un(int, const struct sockaddr_un *);
extern int ID0connect_un(int, const struct sockaddr_un *);
extern int ID0kill(pid_t, int);
extern void ID0setproctitle(const char *);
#if defined(__FreeBSD__) && !defined(NOKLDLOAD)
extern int ID0kldload(const char *);
#endif