2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-02 07:15:27 +00:00

Fix build error when --without-noexec configure option is used.

This commit is contained in:
Todd C. Miller
2011-07-05 12:20:10 -04:00
parent ae34052542
commit 76f427e8d7
2 changed files with 20 additions and 10 deletions

View File

@@ -52,7 +52,9 @@
# define RTLD_GLOBAL 0 # define RTLD_GLOBAL 0
#endif #endif
#ifdef _PATH_SUDO_NOEXEC
const char *noexec_path = _PATH_SUDO_NOEXEC; const char *noexec_path = _PATH_SUDO_NOEXEC;
#endif
/* /*
* Read in /etc/sudo.conf * Read in /etc/sudo.conf
@@ -83,8 +85,10 @@ sudo_read_conf(const char *conf_file)
} }
if (strcasecmp(name, "askpass") == 0) if (strcasecmp(name, "askpass") == 0)
askpass_path = estrdup(path); askpass_path = estrdup(path);
#ifdef _PATH_SUDO_NOEXEC
else if (strcasecmp(name, "noexec") == 0) else if (strcasecmp(name, "noexec") == 0)
noexec_path = estrdup(path); noexec_path = estrdup(path);
#endif
continue; continue;
} }

View File

@@ -512,11 +512,13 @@ command_info_to_details(char * const info[], struct command_details *details)
SET(details->flags, CD_NOEXEC); SET(details->flags, CD_NOEXEC);
break; break;
} }
#ifdef _PATH_SUDO_NOEXEC
/* XXX - deprecated */ /* XXX - deprecated */
if (strncmp("noexec_file=", info[i], sizeof("noexec_file=") - 1) == 0) { if (strncmp("noexec_file=", info[i], sizeof("noexec_file=") - 1) == 0) {
noexec_path = info[i] + sizeof("noexec_file=") - 1; noexec_path = info[i] + sizeof("noexec_file=") - 1;
break; break;
} }
#endif /* _PATH_SUDO_NOEXEC */
break; break;
case 'p': case 'p':
if (strncmp("preserve_groups=", info[i], sizeof("preserve_groups=") - 1) == 0) { if (strncmp("preserve_groups=", info[i], sizeof("preserve_groups=") - 1) == 0) {
@@ -781,8 +783,10 @@ set_project(struct passwd *pw)
static void static void
disable_execute(struct command_details *details) disable_execute(struct command_details *details)
{ {
#ifdef _PATH_SUDO_NOEXEC
char *cp, **ev, **nenvp; char *cp, **ev, **nenvp;
int env_len = 0, env_size = 128; int env_len = 0, env_size = 128;
#endif /* _PATH_SUDO_NOEXEC */
#ifdef HAVE_PRIV_SET #ifdef HAVE_PRIV_SET
/* Solaris privileges, remove PRIV_PROC_EXEC post-execve. */ /* Solaris privileges, remove PRIV_PROC_EXEC post-execve. */
@@ -791,6 +795,7 @@ disable_execute(struct command_details *details)
warning(_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT")); warning(_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
#endif /* HAVE_PRIV_SET */ #endif /* HAVE_PRIV_SET */
#ifdef _PATH_SUDO_NOEXEC
nenvp = emalloc2(env_size, sizeof(char *)); nenvp = emalloc2(env_size, sizeof(char *));
for (ev = details->envp; *ev != NULL; ev++) { for (ev = details->envp; *ev != NULL; ev++) {
if (env_len + 2 > env_size) { if (env_len + 2 > env_size) {
@@ -801,21 +806,21 @@ disable_execute(struct command_details *details)
* Prune out existing preloaded libraries. * Prune out existing preloaded libraries.
* XXX - should save and append instead of replacing. * XXX - should save and append instead of replacing.
*/ */
#if defined(__darwin__) || defined(__APPLE__) # if defined(__darwin__) || defined(__APPLE__)
if (strncmp(*ev, "DYLD_INSERT_LIBRARIES=", sizeof("DYLD_INSERT_LIBRARIES=") - 1) == 0) if (strncmp(*ev, "DYLD_INSERT_LIBRARIES=", sizeof("DYLD_INSERT_LIBRARIES=") - 1) == 0)
continue; continue;
if (strncmp(*ev, "DYLD_FORCE_FLAT_NAMESPACE=", sizeof("DYLD_INSERT_LIBRARIES=") - 1) == 0) if (strncmp(*ev, "DYLD_FORCE_FLAT_NAMESPACE=", sizeof("DYLD_INSERT_LIBRARIES=") - 1) == 0)
continue; continue;
#elif defined(__osf__) || defined(__sgi) # elif defined(__osf__) || defined(__sgi)
if (strncmp(*ev, "_RLD_LIST=", sizeof("_RLD_LIST=") - 1) == 0) if (strncmp(*ev, "_RLD_LIST=", sizeof("_RLD_LIST=") - 1) == 0)
continue; continue;
#elif defined(_AIX) # elif defined(_AIX)
if (strncmp(*ev, "LDR_PRELOAD=", sizeof("LDR_PRELOAD=") - 1) == 0) if (strncmp(*ev, "LDR_PRELOAD=", sizeof("LDR_PRELOAD=") - 1) == 0)
continue; continue;
#else # else
if (strncmp(*ev, "LD_PRELOAD=", sizeof("LD_PRELOAD=") - 1) == 0) if (strncmp(*ev, "LD_PRELOAD=", sizeof("LD_PRELOAD=") - 1) == 0)
continue; continue;
#endif # endif
nenvp[env_len++] = *ev; nenvp[env_len++] = *ev;
} }
@@ -824,22 +829,23 @@ disable_execute(struct command_details *details)
* http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html * http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html
* XXX - need to support 32-bit and 64-bit variants * XXX - need to support 32-bit and 64-bit variants
*/ */
#if defined(__darwin__) || defined(__APPLE__) # if defined(__darwin__) || defined(__APPLE__)
nenvp[env_len++] = "DYLD_FORCE_FLAT_NAMESPACE="; nenvp[env_len++] = "DYLD_FORCE_FLAT_NAMESPACE=";
cp = fmt_string("DYLD_INSERT_LIBRARIES", noexec_path); cp = fmt_string("DYLD_INSERT_LIBRARIES", noexec_path);
#elif defined(__osf__) || defined(__sgi) # elif defined(__osf__) || defined(__sgi)
easprintf(&cp, "_RLD_LIST=%s:DEFAULT", noexec_path); easprintf(&cp, "_RLD_LIST=%s:DEFAULT", noexec_path);
#elif defined(_AIX) # elif defined(_AIX)
cp = fmt_string("LDR_PRELOAD", noexec_path); cp = fmt_string("LDR_PRELOAD", noexec_path);
#else # else
cp = fmt_string("LD_PRELOAD", noexec_path); cp = fmt_string("LD_PRELOAD", noexec_path);
#endif # endif
if (cp == NULL) if (cp == NULL)
error(1, NULL); error(1, NULL);
nenvp[env_len++] = cp; nenvp[env_len++] = cp;
nenvp[env_len] = NULL; nenvp[env_len] = NULL;
details->envp = nenvp; details->envp = nenvp;
#endif /* _PATH_SUDO_NOEXEC */
} }
/* /*