Add setprogname(3) for those without it.
This commit is contained in:
@@ -31,10 +31,21 @@
|
||||
|
||||
#ifdef HAVE_GETPROGNAME
|
||||
|
||||
# ifndef HAVE_SETPROGNAME
|
||||
/* Assume __progname if have getprogname(3) but not setprogname(3). */
|
||||
extern const char *__progname;
|
||||
|
||||
void
|
||||
sudo_setprogname(const char *name)
|
||||
{
|
||||
const char *base = strrchr(name, '/');
|
||||
__progname = base ? base : name;
|
||||
}
|
||||
# endif
|
||||
|
||||
void
|
||||
initprogname2(const char *name, const char * const * allowed)
|
||||
{
|
||||
# ifdef HAVE_SETPROGNAME
|
||||
const char *progname;
|
||||
int i;
|
||||
|
||||
@@ -61,7 +72,6 @@ initprogname2(const char *name, const char * const * allowed)
|
||||
/* Update internal progname if needed. */
|
||||
if (name != progname)
|
||||
setprogname(name);
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,6 +119,13 @@ sudo_getprogname(void)
|
||||
{
|
||||
return progname;
|
||||
}
|
||||
|
||||
void
|
||||
sudo_setprogname(const char *name)
|
||||
{
|
||||
const char *base = strrchr(name, '/');
|
||||
progname = base ? base : name;
|
||||
}
|
||||
#endif /* !HAVE_GETPROGNAME */
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user