/*
- * Copyright (c) 2011-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2011-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
return; \
} while (0)
-#define debug_return_int(rval) \
+#define debug_return_int(ret) \
do { \
- int sudo_debug_rval = (rval); \
+ int sudo_debug_ret = (ret); \
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_size_t(rval) \
+#define debug_return_size_t(ret) \
do { \
- size_t sudo_debug_rval = (rval); \
+ size_t sudo_debug_ret = (ret); \
sudo_debug_exit_size_t(__func__, __FILE__, __LINE__, sudo_debug_subsys,\
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_ssize_t(rval) \
+#define debug_return_ssize_t(ret) \
do { \
- ssize_t sudo_debug_rval = (rval); \
+ ssize_t sudo_debug_ret = (ret); \
sudo_debug_exit_ssize_t(__func__, __FILE__, __LINE__, sudo_debug_subsys,\
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_long(rval) \
+#define debug_return_long(ret) \
do { \
- long sudo_debug_rval = (rval); \
+ long sudo_debug_ret = (ret); \
sudo_debug_exit_long(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_bool(rval) \
+#define debug_return_bool(ret) \
do { \
- bool sudo_debug_rval = (rval); \
+ bool sudo_debug_ret = (ret); \
sudo_debug_exit_bool(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_str(rval) \
+#define debug_return_str(ret) \
do { \
- char *sudo_debug_rval = (rval); \
+ char *sudo_debug_ret = (ret); \
sudo_debug_exit_str(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_const_str(rval) \
+#define debug_return_const_str(ret) \
do { \
- const char *sudo_debug_rval = (rval); \
+ const char *sudo_debug_ret = (ret); \
sudo_debug_exit_str(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_str_masked(rval) \
+#define debug_return_str_masked(ret) \
do { \
- char *sudo_debug_rval = (rval); \
+ char *sudo_debug_ret = (ret); \
sudo_debug_exit_str_masked(__func__, __FILE__, __LINE__, \
- sudo_debug_subsys, sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_subsys, sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_ptr(rval) \
+#define debug_return_ptr(ret) \
do { \
- void *sudo_debug_rval = (rval); \
+ void *sudo_debug_ret = (ret); \
sudo_debug_exit_ptr(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
-#define debug_return_const_ptr(rval) \
+#define debug_return_const_ptr(ret) \
do { \
- const void *sudo_debug_rval = (rval); \
+ const void *sudo_debug_ret = (ret); \
sudo_debug_exit_ptr(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
- sudo_debug_rval); \
- return sudo_debug_rval; \
+ sudo_debug_ret); \
+ return sudo_debug_ret; \
} while (0)
/*
__dso_public void sudo_debug_enter_v1(const char *func, const char *file, int line, int subsys);
__dso_public void sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[]);
__dso_public void sudo_debug_exit_v1(const char *func, const char *file, int line, int subsys);
-__dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, bool rval);
-__dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int line, int subsys, int rval);
-__dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, int subsys, long rval);
-__dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, int subsys, const void *rval);
-__dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, int subsys, size_t rval);
-__dso_public void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, int subsys, ssize_t rval);
-__dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, int subsys, const char *rval);
-__dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, int subsys, const char *rval);
+__dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, bool ret);
+__dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int line, int subsys, int ret);
+__dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, int subsys, long ret);
+__dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, int subsys, const void *ret);
+__dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, int subsys, size_t ret);
+__dso_public void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, int subsys, ssize_t ret);
+__dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, int subsys, const char *ret);
+__dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, int subsys, const char *ret);
__dso_public pid_t sudo_debug_fork_v1(void);
__dso_public int sudo_debug_get_active_instance_v1(void);
__dso_public int sudo_debug_get_fds_v1(unsigned char **fds);
/*
- * Copyright (c) 2008, 2010-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2008, 2010-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* Look up authentication registry for user (SYSTEM in /etc/security/user) and
* set it as the default for the process. This ensures that password and
* group lookups are made against the correct source (files, NIS, LDAP, etc).
- * Does not modify errno even on error since callers do not check rval.
+ * Does not modify errno even on error since callers do not check return value.
*/
int
aix_getauthregistry_v1(char *user, char *saved_registry)
{
int serrno = errno;
- int rval = -1;
+ int ret = -1;
debug_decl(aix_getauthregistry, SUDO_DEBUG_UTIL)
saved_registry[0] = '\0';
sudo_warn(U_("unable to open userdb"));
goto done;
}
- rval = getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR);
- if (rval == 0) {
+ ret = getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR);
+ if (ret == 0) {
/* sizeof(authdb_t) is guaranteed to be 16 */
if (strlcpy(saved_registry, registry, 16) >= 16) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
enduserdb();
} else {
/* Get the process-wide registry. */
- rval = getauthdb(saved_registry);
+ ret = getauthdb(saved_registry);
}
done:
errno = serrno;
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
* This ensures that password and group lookups are made against
* the correct source (files, NIS, LDAP, etc).
* If registry is NULL, look it up based on the user name.
- * Does not modify errno even on error since callers do not check rval.
+ * Does not modify errno even on error since callers do not check return value.
*/
int
aix_setauthdb_v1(char *user)
{
authdb_t regbuf;
int serrno = errno;
- int rval = -1;
+ int ret = -1;
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (user != NULL) {
goto done;
registry = regbuf;
}
- rval = setauthdb(registry, old_registry);
- if (rval != 0) {
+ ret = setauthdb(registry, old_registry);
+ if (ret != 0) {
sudo_warn(U_("unable to switch to registry \"%s\" for %s"),
registry, user);
} else {
}
done:
errno = serrno;
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
* Restore the saved authentication registry, if any.
- * Does not modify errno even on error since callers do not check rval.
+ * Does not modify errno even on error since callers do not check return value.
*/
int
aix_restoreauthdb_v1(void)
{
int serrno = errno;
- int rval = 0;
+ int ret = 0;
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (setauthdb(old_registry, NULL) != 0) {
sudo_warn(U_("unable to restore registry"));
- rval = -1;
+ ret = -1;
} else {
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: setting authentication registry to %s",
__func__, old_registry);
-}
+ }
errno = serrno;
- debug_return_int(rval);
+ debug_return_int(ret);
}
#endif
const char * const mismatch = pattern;
const char *colon;
struct cclass *cc;
- int rval = RANGE_NOMATCH;
+ int result = RANGE_NOMATCH;
size_t len;
if (pattern[0] != '[' || pattern[1] != ':') {
for (cc = cclasses; cc->name != NULL; cc++) {
if (!strncmp(pattern, cc->name, len) && cc->name[len] == '\0') {
if (cc->isctype((unsigned char)test))
- rval = RANGE_MATCH;
+ result = RANGE_MATCH;
break;
}
}
if (cc->name == NULL) {
/* invalid character class, treat as normal text */
*ep = mismatch;
- rval = RANGE_ERROR;
+ result = RANGE_ERROR;
}
- return rval;
+ return result;
}
/* Most MBCS/collation/case issues handled here. Wildcard '*' is not handled.
/*
- * Copyright (c) 2010, 2011, 2013, 2014
+ * Copyright (c) 2010, 2011, 2013-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
char *cp, *grset = NULL;
int ngroups = 1;
int grpsize = *ngroupsp;
- int rval = -1;
+ int ret = -1;
gid_t gid;
/* We support BSD semantics where the first element is the base gid */
}
}
}
- rval = 0;
+ ret = 0;
done:
free(grset);
#endif
*ngroupsp = ngroups;
- return rval;
+ return ret;
}
#elif defined(HAVE_NSS_SEARCH)
process_cstr(const char *instr, int inlen, struct nss_groupsbymem *gbm)
{
const char *user = gbm->username;
- nss_status_t rval = NSS_NOTFOUND;
+ nss_status_t ret = NSS_NOTFOUND;
nss_XbyY_buf_t *buf;
struct group *grp;
char **gr_mem;
}
done:
_nss_XbyY_buf_free(buf);
- return rval;
+ return ret;
}
/*
{
int i, ngroups = 1;
int grpsize = *ngroupsp;
- int rval = -1;
+ int ret = -1;
struct group *grp;
/* We support BSD semantics where the first element is the base gid */
groups[ngroups++] = grp->gr_gid;
}
}
- rval = 0;
+ ret = 0;
done:
endgrent();
*ngroupsp = ngroups;
- return rval;
+ return ret;
}
#endif /* !HAVE_GETGRSET && !HAVE__GETGROUPSBYMEMBER */
#endif /* HAVE_GETGROUPLIST */
/*
- * Copyright (c) 2012, 2014-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2012, 2014-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
sudo_secure_path(const char *path, unsigned int type, uid_t uid, gid_t gid, struct stat *sbp)
{
struct stat sb;
- int rval = SUDO_PATH_MISSING;
+ int ret = SUDO_PATH_MISSING;
debug_decl(sudo_secure_path, SUDO_DEBUG_UTIL)
if (path != NULL && stat(path, &sb) == 0) {
if ((sb.st_mode & _S_IFMT) != type) {
- rval = SUDO_PATH_BAD_TYPE;
+ ret = SUDO_PATH_BAD_TYPE;
} else if (uid != (uid_t)-1 && sb.st_uid != uid) {
- rval = SUDO_PATH_WRONG_OWNER;
+ ret = SUDO_PATH_WRONG_OWNER;
} else if (sb.st_mode & S_IWOTH) {
- rval = SUDO_PATH_WORLD_WRITABLE;
+ ret = SUDO_PATH_WORLD_WRITABLE;
} else if (ISSET(sb.st_mode, S_IWGRP) &&
(gid == (gid_t)-1 || sb.st_gid != gid)) {
- rval = SUDO_PATH_GROUP_WRITABLE;
+ ret = SUDO_PATH_GROUP_WRITABLE;
} else {
- rval = SUDO_PATH_SECURE;
+ ret = SUDO_PATH_SECURE;
}
if (sbp)
(void) memcpy(sbp, &sb, sizeof(struct stat));
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
/*
- * Copyright (c) 2011-2012, 2014-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2011-2012, 2014-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
int
sudo_setgroups_v1(int ngids, const GETGROUPS_T *gids)
{
- int maxgids, rval;
+ int maxgids, ret;
debug_decl(sudo_setgroups, SUDO_DEBUG_UTIL)
- rval = setgroups(ngids, (GETGROUPS_T *)gids);
- if (rval == -1 && errno == EINVAL) {
+ ret = setgroups(ngids, (GETGROUPS_T *)gids);
+ if (ret == -1 && errno == EINVAL) {
/* Too many groups, try again with fewer. */
maxgids = (int)sysconf(_SC_NGROUPS_MAX);
if (maxgids == -1)
maxgids = NGROUPS_MAX;
if (ngids > maxgids)
- rval = setgroups(maxgids, (GETGROUPS_T *)gids);
+ ret = setgroups(maxgids, (GETGROUPS_T *)gids);
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
- * Copyright (c) 2013-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2013-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
sudo_strtoid_v1(const char *p, const char *sep, char **endp, const char **errstr)
{
char *ep;
- id_t rval = 0;
+ id_t ret = 0;
bool valid = false;
debug_decl(sudo_strtoid, SUDO_DEBUG_UTIL)
*errstr = N_("value too small");
goto done;
}
- rval = (id_t)lval;
+ ret = (id_t)lval;
} else {
unsigned long ulval = strtoul(p, &ep, 10);
if (ep != p) {
*errstr = N_("value too large");
goto done;
}
- rval = (id_t)ulval;
+ ret = (id_t)ulval;
}
if (errstr != NULL)
*errstr = NULL;
if (endp != NULL)
*endp = ep;
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
- * Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2009-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
parse_variable(const char *entry, const char *conf_file, unsigned int lineno)
{
struct sudo_conf_table *var;
- int rval;
+ int ret;
debug_decl(parse_variable, SUDO_DEBUG_UTIL)
for (var = sudo_conf_var_table; var->name != NULL; var++) {
entry += var->namelen + 1;
while (isblank((unsigned char)*entry))
entry++;
- rval = var->parser(entry, conf_file, lineno);
- sudo_debug_printf(rval ? SUDO_DEBUG_INFO : SUDO_DEBUG_ERROR,
+ ret = var->parser(entry, conf_file, lineno);
+ sudo_debug_printf(ret ? SUDO_DEBUG_INFO : SUDO_DEBUG_ERROR,
"%s: %s:%u: Set %s %s", __func__, conf_file,
lineno, var->name, entry);
- debug_return_int(rval);
+ debug_return_int(ret);
}
}
sudo_debug_printf(SUDO_DEBUG_WARN, "%s: %s:%u: unknown setting %s",
void
sudo_debug_exit_int_v1(const char *func, const char *file, int line,
- int subsys, int rval)
+ int subsys, int ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %d", func, file, line, rval);
+ "<- %s @ %s:%d := %d", func, file, line, ret);
}
void
sudo_debug_exit_long_v1(const char *func, const char *file, int line,
- int subsys, long rval)
+ int subsys, long ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %ld", func, file, line, rval);
+ "<- %s @ %s:%d := %ld", func, file, line, ret);
}
void
sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
- int subsys, size_t rval)
+ int subsys, size_t ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %zu", func, file, line, rval);
+ "<- %s @ %s:%d := %zu", func, file, line, ret);
}
void
sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
- int subsys, ssize_t rval)
+ int subsys, ssize_t ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %zd", func, file, line, rval);
+ "<- %s @ %s:%d := %zd", func, file, line, ret);
}
void
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
- int subsys, bool rval)
+ int subsys, bool ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %s", func, file, line, rval ? "true" : "false");
+ "<- %s @ %s:%d := %s", func, file, line, ret ? "true" : "false");
}
void
sudo_debug_exit_str_v1(const char *func, const char *file, int line,
- int subsys, const char *rval)
+ int subsys, const char *ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %s", func, file, line, rval ? rval : "(null)");
+ "<- %s @ %s:%d := %s", func, file, line, ret ? ret : "(null)");
}
void
sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line,
- int subsys, const char *rval)
+ int subsys, const char *ret)
{
static const char stars[] = "********************************************************************************";
- int len = rval ? strlen(rval) : sizeof("(null)") - 1;
+ int len = ret ? strlen(ret) : sizeof("(null)") - 1;
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %.*s", func, file, line, len, rval ? stars : "(null)");
+ "<- %s @ %s:%d := %.*s", func, file, line, len, ret ? stars : "(null)");
}
void
sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
- int subsys, const void *rval)
+ int subsys, const void *ret)
{
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %p", func, file, line, rval);
+ "<- %s @ %s:%d := %p", func, file, line, ret);
}
void
/*
- * Copyright (c) 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
io_log_output(const char *buf, unsigned int len)
{
const char *cp, *ep;
- bool rval = true;
+ bool ret = true;
ignore_result(fwrite(buf, len, 1, output));
/*
*/
for (cp = buf, ep = buf + len; cp < ep; cp++) {
if (cp + 5 < ep && memcmp(cp, "honk!", 5) == 0) {
- rval = false;
+ ret = false;
break;
}
}
- return rval;
+ return ret;
}
__dso_public struct policy_plugin sample_policy = {
/*
- * Copyright (c) 1999-2005, 2007-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1999-2005, 2007-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
{
char *pass, *message = NULL;
int result = 1, reenter = 0;
- int rval = AUTH_SUCCESS;
+ int ret = AUTH_SUCCESS;
debug_decl(sudo_aix_verify, SUDOERS_DEBUG_AUTH)
do {
memset(&repl, 0, sizeof(repl));
sudo_conv(1, &msg, &repl, NULL);
}
- rval = pass ? AUTH_FAILURE : AUTH_INTR;
+ ret = pass ? AUTH_FAILURE : AUTH_INTR;
}
free(message);
- debug_return_int(rval);
+ debug_return_int(ret);
}
int
/*
- * Copyright (c) 1999-2005, 2007, 2010-2012, 2014-2015
+ * Copyright (c) 1999-2005, 2007, 2010-2012, 2014-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2002 Michael Stroucken <michael@stroucken.org>
*
sudo_securid_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_conv_callback *callback)
{
SDI_HANDLE *sd = (SDI_HANDLE *) auth->data;
- int rval;
+ int ret;
debug_decl(sudo_securid_verify, SUDOERS_DEBUG_AUTH)
pass = auth_getpass("Enter your PASSCODE: ",
/* Have ACE verify password */
switch (SD_Check(*sd, pass, pw->pw_name)) {
case ACM_OK:
- rval = AUTH_SUCESS;
+ ret = AUTH_SUCESS;
break;
case ACE_UNDEFINED_PASSCODE:
sudo_warnx(U_("invalid passcode length for SecurID"));
- rval = AUTH_FATAL;
+ ret = AUTH_FATAL;
break;
case ACE_UNDEFINED_USERNAME:
sudo_warnx(U_("invalid username length for SecurID"));
- rval = AUTH_FATAL;
+ ret = AUTH_FATAL;
break;
case ACE_ERR_INVALID_HANDLE:
sudo_warnx(U_("invalid Authentication Handle for SecurID"));
- rval = AUTH_FATAL;
+ ret = AUTH_FATAL;
break;
case ACM_ACCESS_DENIED:
- rval = AUTH_FAILURE;
+ ret = AUTH_FAILURE;
break;
case ACM_NEXT_CODE_REQUIRED:
def_passwd_timeout * 60, SUDO_CONV_PROMPT_ECHO_OFF, callback);
if (SD_Next(*sd, pass) == ACM_OK) {
- rval = AUTH_SUCCESS;
+ ret = AUTH_SUCCESS;
break;
}
- rval = AUTH_FAILURE;
+ ret = AUTH_FAILURE;
break;
case ACM_NEW_PIN_REQUIRED:
"Your SecurID access has not yet been set up.\n");
sudo_printf(SUDO_CONV_ERROR_MSG,
"Please set up a PIN before you try to authenticate.\n");
- rval = AUTH_FATAL;
+ ret = AUTH_FATAL;
break;
default:
sudo_warnx(U_("unknown SecurID error"));
- rval = AUTH_FATAL;
+ ret = AUTH_FATAL;
break;
}
}
/* Return stored state to calling process */
- debug_return_int(rval);
+ debug_return_int(ret);
}
#endif /* HAVE_SECURID */
/*
- * Copyright (c) 1999-2005, 2008-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1999-2005, 2008-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
struct sudo_conv_callback *callback)
{
unsigned int ntries;
- int rval, status, success = AUTH_FAILURE;
+ int ret, status, success = AUTH_FAILURE;
sudo_auth *auth;
sigset_t mask, omask;
sigaction_t sa, saved_sigtstp;
switch (success) {
case AUTH_SUCCESS:
- rval = true;
+ ret = true;
break;
case AUTH_INTR:
case AUTH_FAILURE:
if (ntries != 0)
validated |= FLAG_BAD_PASSWORD;
log_auth_failure(validated, ntries);
- rval = false;
+ ret = false;
break;
case AUTH_FATAL:
default:
log_auth_failure(validated | FLAG_AUTH_ERROR, 0);
- rval = -1;
+ ret = -1;
break;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
/*
- * Copyright (c) 1993-1996,1998-2005, 2007-2015
+ * Copyright (c) 1993-1996,1998-2005, 2007-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
struct sudo_conv_callback cb, *callback = NULL;
struct getpass_closure closure;
int status = TS_ERROR;
- int rval = -1;
+ int ret = -1;
char *prompt;
bool lectured;
debug_decl(check_user_interactive, SUDOERS_DEBUG_AUTH)
case TS_CURRENT:
/* Time stamp file is valid and current. */
if (!ISSET(validated, FLAG_CHECK_USER)) {
- rval = true;
+ ret = true;
break;
}
/* FALLTHROUGH */
if (prompt == NULL)
goto done;
- rval = verify_user(closure.auth_pw, prompt, validated, callback);
- if (rval == true && lectured)
+ ret = verify_user(closure.auth_pw, prompt, validated, callback);
+ if (ret == true && lectured)
(void)set_lectured(); /* lecture error not fatal */
free(prompt);
break;
* Only update time stamp if user was validated.
* Failure to update the time stamp is not a fatal error.
*/
- if (rval == true && ISSET(validated, VALIDATE_SUCCESS) && status != TS_ERROR)
+ if (ret == true && ISSET(validated, VALIDATE_SUCCESS) && status != TS_ERROR)
(void)timestamp_update(closure.cookie, closure.auth_pw);
done:
if (closure.cookie != NULL)
timestamp_close(closure.cookie);
sudo_pw_delref(closure.auth_pw);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
check_user(int validated, int mode)
{
struct passwd *auth_pw;
- int rval = -1;
+ int ret = -1;
debug_decl(check_user, SUDOERS_DEBUG_AUTH)
/*
* If the user is not changing uid/gid, no need for a password.
*/
if (!def_authenticate || user_is_exempt()) {
- rval = true;
+ ret = true;
goto done;
}
if (user_uid == 0 || (user_uid == runas_pw->pw_uid &&
if (runas_privs == NULL && runas_limitprivs == NULL)
#endif
{
- rval = true;
+ ret = true;
goto done;
}
}
- rval = check_user_interactive(validated, mode, auth_pw);
+ ret = check_user_interactive(validated, mode, auth_pw);
done:
sudo_auth_cleanup(auth_pw);
sudo_pw_delref(auth_pw);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
bool
user_is_exempt(void)
{
- bool rval = false;
+ bool ret = false;
debug_decl(user_is_exempt, SUDOERS_DEBUG_AUTH)
if (def_exempt_group)
- rval = user_in_group(sudo_user.pw, def_exempt_group);
- debug_return_bool(rval);
+ ret = user_in_group(sudo_user.pw, def_exempt_group);
+ debug_return_bool(ret);
}
/*
static int
sudo_putenv(char *str, bool dupcheck, bool overwrite)
{
- int rval;
+ int ret;
debug_decl(sudo_putenv, SUDOERS_DEBUG_ENV)
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_putenv: %s", str);
- rval = sudo_putenv_nodebug(str, dupcheck, overwrite);
- if (rval == -1) {
+ ret = sudo_putenv_nodebug(str, dupcheck, overwrite);
+ if (ret == -1) {
#ifdef ENV_DEBUG
if (env.envp[env.env_len] != NULL)
sudo_warnx(U_("sudo_putenv: corrupted envp, length mismatch"));
#endif
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
{
char *estring;
size_t esize;
- int rval = -1;
+ int ret = -1;
debug_decl(sudo_setenv2, SUDOERS_DEBUG_ENV)
esize = strlen(var) + 1 + strlen(val) + 1;
sudo_warnx(U_("internal error, %s overflow"), __func__);
errno = EOVERFLOW;
} else {
- rval = sudo_putenv(estring, dupcheck, overwrite);
+ ret = sudo_putenv(estring, dupcheck, overwrite);
}
- if (rval == -1)
+ if (ret == -1)
free(estring);
else
sudoers_gc_add(GC_PTR, estring);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
char *ep, *estring = NULL;
const char *cp;
size_t esize;
- int rval = -1;
+ int ret = -1;
if (var == NULL || *var == '\0') {
errno = EINVAL;
}
*ep = '\0';
- rval = sudo_putenv_nodebug(estring, true, overwrite);
+ ret = sudo_putenv_nodebug(estring, true, overwrite);
done:
- if (rval == -1)
+ if (ret == -1)
free(estring);
else
sudoers_gc_add(GC_PTR, estring);
- return rval;
+ return ret;
}
/*
int
sudo_unsetenv(const char *name)
{
- int rval;
+ int ret;
debug_decl(sudo_unsetenv, SUDOERS_DEBUG_ENV)
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_unsetenv: %s", name);
- rval = sudo_unsetenv_nodebug(name);
+ ret = sudo_unsetenv_nodebug(name);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
env_merge(char * const envp[])
{
char * const *ep;
- bool rval = true;
+ bool ret = true;
debug_decl(env_merge, SUDOERS_DEBUG_ENV)
for (ep = envp; *ep != NULL; ep++) {
bool overwrite = def_env_reset ? !env_should_keep(*ep) : env_should_delete(*ep);
if (sudo_putenv(*ep, true, overwrite) == -1) {
/* XXX cannot undo on failure */
- rval = false;
+ ret = false;
break;
}
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#endif /* HAVE_PAM */
insert_env_vars(char * const envp[])
{
char * const *ep;
- bool rval = true;
+ bool ret = true;
debug_decl(insert_env_vars, SUDOERS_DEBUG_ENV)
/* Add user-specified environment variables. */
for (ep = envp; *ep != NULL; ep++) {
/* XXX - no undo on failure */
if (sudo_putenv(*ep, true, true) == -1) {
- rval = false;
+ ret = false;
break;
}
}
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
{
char * const *ep;
char *eq, errbuf[4096];
- bool okvar, rval = true;
+ bool okvar, ret = true;
debug_decl(validate_env_vars, SUDOERS_DEBUG_ENV)
if (env_vars == NULL)
/* XXX - audit? */
log_warningx(0,
N_("sorry, you are not allowed to set the following environment variables: %s"), errbuf);
- rval = false;
+ ret = false;
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
read_env_file(const char *path, int overwrite)
{
FILE *fp;
- bool rval = true;
+ bool ret = true;
char *cp, *var, *val, *line = NULL;
size_t var_len, val_len, linesize = 0;
debug_decl(read_env_file, SUDOERS_DEBUG_ENV)
if ((fp = fopen(path, "r")) == NULL) {
if (errno != ENOENT)
- rval = false;
- debug_return_bool(rval);
+ ret = false;
+ debug_return_bool(ret);
}
while (sudo_parseln(&line, &linesize, NULL, fp, PARSELN_CONT_IGN) != -1) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to allocate memory");
/* XXX - no undo on failure */
- rval = false;
+ ret = false;
break;
}
memcpy(cp, var, var_len + 1); /* includes '=' */
sudoers_gc_add(GC_PTR, cp);
if (sudo_putenv(cp, true, overwrite) == -1) {
/* XXX - no undo on failure */
- rval = false;
+ ret = false;
break;
}
}
free(line);
fclose(fp);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
bool
/*
- * Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2015
+ * Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
bool
sudo_goodpath(const char *path, struct stat *sbp)
{
- bool rval = false;
+ bool ret = false;
debug_decl(sudo_goodpath, SUDOERS_DEBUG_UTIL)
if (path != NULL) {
if (stat(path, sbp) == 0) {
/* Make sure path describes an executable regular file. */
if (S_ISREG(sbp->st_mode) && ISSET(sbp->st_mode, 0111))
- rval = true;
+ ret = true;
else
errno = EACCES;
}
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#define YYPREFIX "sudoers"
#line 2 "gram.y"
/*
- * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2015
+ * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
short *yysslim;
YYSTYPE *yyvs;
unsigned int yystacksize;
+int yyparse(void);
#line 859 "gram.y"
void
sudoerserror(const char *s)
struct member_list *binding;
struct defaults *d, *d_next;
struct userspec *us, *us_next;
- bool rval = true;
+ bool ret = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER)
TAILQ_FOREACH_SAFE(us, &userspecs, entries, us_next) {
if (!init_aliases()) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = false;
+ ret = false;
}
free(sudoers);
if (path != NULL) {
if ((sudoers = strdup(path)) == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = false;
+ ret = false;
}
} else {
sudoers = NULL;
errorfile = sudoers;
sudoers_warnings = !quiet;
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
-#line 938 "gram.c"
+#line 939 "gram.c"
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
#if defined(__cplusplus) || defined(__STDC__)
static int yygrowstack(void)
}
}
break;
-#line 2031 "gram.c"
+#line 2032 "gram.c"
}
yyssp -= yym;
yystate = *yyssp;
%{
/*
- * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2015
+ * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
struct member_list *binding;
struct defaults *d, *d_next;
struct userspec *us, *us_next;
- bool rval = true;
+ bool ret = true;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER)
TAILQ_FOREACH_SAFE(us, &userspecs, entries, us_next) {
if (!init_aliases()) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = false;
+ ret = false;
}
free(sudoers);
if (path != NULL) {
if ((sudoers = strdup(path)) == NULL) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = false;
+ ret = false;
}
} else {
sudoers = NULL;
errorfile = sudoers;
sudoers_warnings = !quiet;
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
- * Copyright (c) 2010-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
{
char *addrinfo, *addr, *mask, *last;
struct interface *ifp;
- bool rval = false;
+ bool ret = false;
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF)
if ((addrinfo = strdup(ai)) == NULL)
}
SLIST_INSERT_HEAD(&interfaces, ifp, entries);
}
- rval = true;
+ ret = true;
done:
free(addrinfo);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
struct interface_list *
int i, len, fd = -1;
unsigned long id = 0;
ssize_t nread;
- bool rval = false;
+ bool ret = false;
char pathbuf[PATH_MAX];
static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
debug_decl(io_nextid, SUDOERS_DEBUG_UTIL)
warned = true;
goto done;
}
- rval = true;
+ ret = true;
done:
if (fd != -1)
close(fd);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
char * const *av;
FILE *fp;
int fd;
- bool rval;
+ bool ret;
debug_decl(write_info_log, SUDOERS_DEBUG_UTIL)
pathbuf[len] = '\0';
fputc('\n', fp);
fflush(fp);
- rval = !ferror(fp);
+ ret = !ferror(fp);
fclose(fp);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
static int
char * const *cur;
const char *cp, *plugin_path = NULL;
size_t len;
- int i, rval = -1;
+ int i, ret = -1;
debug_decl(sudoers_io_open, SUDOERS_DEBUG_PLUGIN)
sudo_conv = conversation;
* Pull iolog settings out of command_info.
*/
if (!iolog_deserialize_info(&iolog_details, user_info, command_info)) {
- rval = false;
+ ret = false;
goto done;
}
}
memcpy(tofree, _PATH_SUDO_IO_LOGDIR, sizeof(_PATH_SUDO_IO_LOGDIR));
if (!io_nextid(tofree, NULL, sessid)) {
- rval = false;
+ ret = false;
goto done;
}
snprintf(tofree + sizeof(_PATH_SUDO_IO_LOGDIR), sizeof(sessid) + 2,
if (!io_log_files[IOFD_TTYOUT].enabled)
sudoers_io.log_ttyout = NULL;
- rval = true;
+ ret = true;
done:
free(tofree);
sudo_freegrcache();
/* Ignore errors if they occur if the policy says so. */
- if (rval == -1 && iolog_details.ignore_iolog_errors)
- rval = 0;
+ if (ret == -1 && iolog_details.ignore_iolog_errors)
+ ret = 0;
- debug_return_int(rval);
+ debug_return_int(ret);
}
static void
{
struct timeval now, delay;
const char *errstr = NULL;
- int rval = true;
+ int ret = true;
debug_decl(sudoers_io_version, SUDOERS_DEBUG_PLUGIN)
if (io_log_files[idx].fd.v == NULL) {
int errnum;
errstr = gzerror(io_log_files[idx].fd.g, &errnum);
- rval = -1;
+ ret = -1;
}
} else
#endif
{
if (fwrite(buf, 1, len, io_log_files[idx].fd.f) != len) {
errstr = strerror(errno);
- rval = -1;
+ ret = -1;
}
}
sudo_timevalsub(&now, &last_time, &delay);
int errnum;
errstr = gzerror(io_log_files[IOFD_TIMING].fd.g, &errnum);
- rval = -1;
+ ret = -1;
}
} else
#endif
if (fprintf(io_log_files[IOFD_TIMING].fd.f, "%d %f %u\n", idx,
delay.tv_sec + ((double)delay.tv_usec / 1000000), len) < 0) {
errstr = strerror(errno);
- rval = -1;
+ ret = -1;
}
}
last_time.tv_sec = now.tv_sec;
last_time.tv_usec = now.tv_usec;
- if (rval == -1) {
+ if (ret == -1) {
if (errstr != NULL && !warned) {
/* Only warn about I/O log file errors once. */
log_warning(SLOG_SEND_MAIL,
/* Ignore errors if they occur if the policy says so. */
if (iolog_details.ignore_iolog_errors)
- rval = true;
+ ret = true;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
char *escaped_domain = NULL, *escaped_user = NULL;
char *escaped_host = NULL, *escaped_shost = NULL, *filt = NULL;
int filt_len, rc;
- bool rval = false;
+ bool ret = false;
debug_decl(sudo_netgroup_lookup, SUDOERS_DEBUG_LDAP);
if (ldap_conf.timeout > 0) {
goto done;
}
}
- rval = true;
+ ret = true;
goto done;
oom:
free(escaped_shost);
free(filt);
ldap_msgfree(result);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
/*
- * Copyright (c) 1994-1996, 1998-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1994-1996, 1998-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
static bool warned = false;
const char *timestr;
int len, oldlocale;
- bool rval = false;
+ bool ret = false;
char *full_line;
mode_t oldmask;
FILE *fp;
}
goto done;
}
- rval = true;
+ ret = true;
done:
if (fp != NULL)
(void) fclose(fp);
sudoers_setlocale(oldlocale, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
const char *message;
char *logline;
int oldlocale;
- bool uid_changed, rval = true;
+ bool uid_changed, ret = true;
debug_decl(log_denial, SUDOERS_DEBUG_LOGGING)
/* Handle auditing first (audit_failure() handles the locale itself). */
if (def_syslog)
do_syslog(def_syslog_badpri, logline);
if (def_logfile && !do_logfile(logline))
- rval = false;
+ ret = false;
if (uid_changed) {
if (!restore_perms())
- rval = false; /* XXX - return -1 instead? */
+ ret = false; /* XXX - return -1 instead? */
}
free(logline);
}
sudoers_setlocale(oldlocale, NULL);
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
bool
log_failure(int status, int flags)
{
- bool rval, inform_user = true;
+ bool ret, inform_user = true;
debug_decl(log_failure, SUDOERS_DEBUG_LOGGING)
/* The user doesn't always get to see the log message (path info). */
if (!ISSET(status, FLAG_NO_USER | FLAG_NO_HOST) && def_path_info &&
(flags == NOT_FOUND_DOT || flags == NOT_FOUND))
inform_user = false;
- rval = log_denial(status, inform_user);
+ ret = log_denial(status, inform_user);
if (!inform_user) {
/*
sudo_warnx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
log_auth_failure(int status, unsigned int tries)
{
int flags = 0;
- bool rval = true;
+ bool ret = true;
debug_decl(log_auth_failure, SUDOERS_DEBUG_LOGGING)
/* Handle auditing first. */
* If sudoers denied the command we'll log that separately.
*/
if (ISSET(status, FLAG_BAD_PASSWORD))
- rval = log_warningx(flags, INCORRECT_PASSWORD_ATTEMPT, tries);
+ ret = log_warningx(flags, INCORRECT_PASSWORD_ATTEMPT, tries);
else if (ISSET(status, FLAG_NON_INTERACTIVE))
- rval = log_warningx(flags, N_("a password is required"));
+ ret = log_warningx(flags, N_("a password is required"));
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
{
char *logline;
int oldlocale;
- bool uid_changed, rval = true;
+ bool uid_changed, ret = true;
debug_decl(log_allowed, SUDOERS_DEBUG_LOGGING)
/* Log and mail messages should be in the sudoers locale. */
if (def_syslog)
do_syslog(def_syslog_goodpri, logline);
if (def_logfile && !do_logfile(logline))
- rval = false;
+ ret = false;
if (uid_changed) {
if (!restore_perms())
- rval = false; /* XXX - return -1 instead? */
+ ret = false; /* XXX - return -1 instead? */
}
free(logline);
sudoers_setlocale(oldlocale, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
{
int oldlocale, serrno = errno;
char *logline, *message;
- bool uid_changed, rval = true;
+ bool uid_changed, ret = true;
va_list ap2;
int len;
debug_decl(vlog_error, SUDOERS_DEBUG_LOGGING)
}
if (len == -1) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = false;
+ ret = false;
goto done;
}
logline = new_logline(message, ISSET(flags, SLOG_USE_ERRNO) ? serrno : 0);
free(message);
if (logline == NULL) {
- rval = false;
+ ret = false;
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
if (def_syslog)
do_syslog(def_syslog_badpri, logline);
if (def_logfile && !do_logfile(logline))
- rval = false;
+ ret = false;
}
if (uid_changed) {
if (!restore_perms())
- rval = false;
+ ret = false;
}
free(logline);
va_end(ap2);
sudoers_setlocale(oldlocale, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
bool
log_warning(int flags, const char *fmt, ...)
{
va_list ap;
- bool rval;
+ bool ret;
debug_decl(log_error, SUDOERS_DEBUG_LOGGING)
/* Log the error. */
va_start(ap, fmt);
- rval = vlog_warning(flags|SLOG_USE_ERRNO, fmt, ap);
+ ret = vlog_warning(flags|SLOG_USE_ERRNO, fmt, ap);
va_end(ap);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
bool
log_warningx(int flags, const char *fmt, ...)
{
va_list ap;
- bool rval;
+ bool ret;
debug_decl(log_error, SUDOERS_DEBUG_LOGGING)
/* Log the error. */
va_start(ap, fmt);
- rval = vlog_warning(flags, fmt, ap);
+ ret = vlog_warning(flags, fmt, ap);
va_end(ap);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#define MAX_MAILFLAGS 63
{
struct member *m;
struct alias *a;
- int rval, matched = UNSPEC;
+ int rc, matched = UNSPEC;
debug_decl(userlist_matches, SUDOERS_DEBUG_MATCH)
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
break;
case ALIAS:
if ((a = alias_get(m->name, USERALIAS)) != NULL) {
- rval = userlist_matches(pw, &a->members);
- if (rval != UNSPEC)
- matched = m->negated ? !rval : rval;
+ rc = userlist_matches(pw, &a->members);
+ if (rc != UNSPEC)
+ matched = m->negated ? !rc : rc;
alias_put(a);
break;
}
{
struct member *m;
struct alias *a;
- int rval;
+ int rc;
int user_matched = UNSPEC;
int group_matched = UNSPEC;
debug_decl(runaslist_matches, SUDOERS_DEBUG_MATCH)
break;
case ALIAS:
if ((a = alias_get(m->name, RUNASALIAS)) != NULL) {
- rval = runaslist_matches(&a->members, &empty,
+ rc = runaslist_matches(&a->members, &empty,
matching_user, NULL);
- if (rval != UNSPEC)
- user_matched = m->negated ? !rval : rval;
+ if (rc != UNSPEC)
+ user_matched = m->negated ? !rc : rc;
alias_put(a);
break;
}
break;
case ALIAS:
if ((a = alias_get(m->name, RUNASALIAS)) != NULL) {
- rval = runaslist_matches(&empty, &a->members,
+ rc = runaslist_matches(&empty, &a->members,
NULL, matching_group);
- if (rval != UNSPEC)
- group_matched = m->negated ? !rval : rval;
+ if (rc != UNSPEC)
+ group_matched = m->negated ? !rc : rc;
alias_put(a);
break;
}
{
struct member *m;
struct alias *a;
- int rval, matched = UNSPEC;
+ int rc, matched = UNSPEC;
debug_decl(hostlist_matches, SUDOERS_DEBUG_MATCH)
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
break;
case ALIAS:
if ((a = alias_get(m->name, HOSTALIAS)) != NULL) {
- rval = hostlist_matches(pw, &a->members);
- if (rval != UNSPEC)
- matched = m->negated ? !rval : rval;
+ rc = hostlist_matches(pw, &a->members);
+ if (rc != UNSPEC)
+ matched = m->negated ? !rc : rc;
alias_put(a);
break;
}
{
struct alias *a;
struct sudo_command *c;
- int rval, matched = UNSPEC;
+ int rc, matched = UNSPEC;
debug_decl(cmnd_matches, SUDOERS_DEBUG_MATCH)
switch (m->type) {
break;
case ALIAS:
if ((a = alias_get(m->name, CMNDALIAS)) != NULL) {
- rval = cmndlist_matches(&a->members);
- if (rval != UNSPEC)
- matched = m->negated ? !rval : rval;
+ rc = cmndlist_matches(&a->members);
+ if (rc != UNSPEC)
+ matched = m->negated ? !rc : rc;
alias_put(a);
}
break;
if (!initialized) {
size_t host_name_max;
- int rval;
+ int rc;
# ifdef _SC_HOST_NAME_MAX
host_name_max = (size_t)sysconf(_SC_HOST_NAME_MAX);
if (domain != NULL) {
# ifdef SI_SRPC_DOMAIN
domain[0] = '\0';
- rval = sysinfo(SI_SRPC_DOMAIN, domain, host_name_max + 1);
+ rc = sysinfo(SI_SRPC_DOMAIN, domain, host_name_max + 1);
# else
- rval = getdomainname(domain, host_name_max + 1);
+ rc = getdomainname(domain, host_name_max + 1);
# endif
- if (rval != -1 && domain[0] != '\0') {
+ if (rc != -1 && domain[0] != '\0') {
const char *cp;
for (cp = domain; *cp != '\0'; cp++) {
struct member *match;
struct privilege *priv;
struct userspec *us;
- int rval = 1;
+ int ret = 1;
int host_match, runas_match, cmnd_match;
debug_decl(sudo_file_display_cmnd, SUDOERS_DEBUG_NSS)
if (match != NULL && !match->negated) {
const int len = sudo_printf(SUDO_CONV_INFO_MSG, "%s%s%s\n",
safe_cmnd, user_args ? " " : "", user_args ? user_args : "");
- rval = len < 0 ? -1 : 0;
+ ret = len < 0 ? -1 : 0;
}
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
char **command_infop[], char **argv_out[], char **user_env_out[])
{
struct sudoers_exec_args exec_args;
- int rval;
+ int ret;
debug_decl(sudoers_policy_check, SUDOERS_DEBUG_PLUGIN)
if (!ISSET(sudo_mode, MODE_EDIT))
exec_args.envp = user_env_out;
exec_args.info = command_infop;
- rval = sudoers_policy_main(argc, argv, 0, env_add, &exec_args);
- if (rval == true && sudo_version >= SUDO_API_MKVERSION(1, 3)) {
+ ret = sudoers_policy_main(argc, argv, 0, env_add, &exec_args);
+ if (ret == true && sudo_version >= SUDO_API_MKVERSION(1, 3)) {
/* Unset close function if we don't need it to avoid extra process. */
if (!def_log_input && !def_log_output && !def_use_pty &&
!sudo_auth_needs_end_session())
sudoers_policy.close = NULL;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
sudoers_policy_list(int argc, char * const argv[], int verbose,
const char *list_user)
{
- int rval;
+ int ret;
debug_decl(sudoers_policy_list, SUDOERS_DEBUG_PLUGIN)
user_cmnd = "list";
debug_return_int(-1);
}
}
- rval = sudoers_policy_main(argc, argv, I_LISTPW, NULL, NULL);
+ ret = sudoers_policy_main(argc, argv, I_LISTPW, NULL, NULL);
if (list_user) {
sudo_pw_delref(list_pw);
list_pw = NULL;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
{
const struct cache_item *ci1 = (const struct cache_item *) v1;
const struct cache_item *ci2 = (const struct cache_item *) v2;
- int rval = strcmp(ci1->k.name, ci2->k.name);
- if (rval == 0)
- rval = strcmp(ci1->registry, ci2->registry);
- return rval;
+ int ret = strcmp(ci1->k.name, ci2->k.name);
+ if (ret == 0)
+ ret = strcmp(ci1->registry, ci2->registry);
+ return ret;
}
void
{
struct sudo_nss *nss, *nss_next;
int oldlocale, sources = 0;
- int rval = -1;
+ int ret = -1;
debug_decl(sudoers_policy_init, SUDOERS_DEBUG_PLUGIN)
bindtextdomain("sudoers", LOCALEDIR);
/* Set login class if applicable (after sudoers is parsed). */
if (set_loginclass(runas_pw ? runas_pw : sudo_user.pw))
- rval = true;
+ ret = true;
cleanup:
if (!restore_perms())
- rval = -1;
+ ret = -1;
/* Restore user's locale. */
sudo_warn_set_locale_func(NULL);
sudoers_setlocale(oldlocale, NULL);
- debug_return_int(rval);
+ debug_return_int(ret);
}
int
struct sudo_nss *nss;
bool nopass = false;
int cmnd_status = -1, oldlocale, validated;
- int rval = -1;
+ int ret = -1;
debug_decl(sudoers_policy_main, SUDOERS_DEBUG_PLUGIN)
sudo_warn_set_locale_func(sudoers_warn_setlocale);
/* If no command line args and "shell_noargs" is not set, error out. */
if (ISSET(sudo_mode, MODE_IMPLIED_SHELL) && !def_shell_noargs) {
/* Not an audit event. */
- rval = -2; /* usage error */
+ ret = -2; /* usage error */
goto done;
}
}
goto bad;
default:
- /* some other error, rval is -1. */
+ /* some other error, ret is -1. */
goto done;
}
switch (sudo_mode & MODE_MASK) {
case MODE_CHECK:
- rval = display_cmnd(snl, list_pw ? list_pw : sudo_user.pw);
+ ret = display_cmnd(snl, list_pw ? list_pw : sudo_user.pw);
break;
case MODE_LIST:
- rval = display_privs(snl, list_pw ? list_pw : sudo_user.pw);
+ ret = display_privs(snl, list_pw ? list_pw : sudo_user.pw);
break;
case MODE_VALIDATE:
/* Nothing to do. */
- rval = true;
+ ret = true;
break;
case MODE_RUN:
case MODE_EDIT:
- /* rval set by sudoers_policy_exec_setup() below. */
+ /* ret set by sudoers_policy_exec_setup() below. */
break;
default:
/* Should not happen. */
group_plugin_unload();
if (ISSET(sudo_mode, (MODE_VALIDATE|MODE_CHECK|MODE_LIST))) {
- /* rval already set appropriately */
+ /* ret already set appropriately */
goto done;
}
}
/* Setup execution environment to pass back to front-end. */
- rval = sudoers_policy_exec_setup(edit_argv ? edit_argv : NewArgv,
+ ret = sudoers_policy_exec_setup(edit_argv ? edit_argv : NewArgv,
env_get(), cmnd_umask, iolog_path, closure);
/* Zero out stashed copy of environment, it is owned by the front-end. */
goto done;
bad:
- rval = false;
+ ret = false;
done:
if (!rewind_perms())
- rval = -1;
+ ret = -1;
restore_nproc();
sudo_warn_set_locale_func(NULL);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
static int
set_cmnd(void)
{
- int rval = FOUND;
+ int ret = FOUND;
char *path = user_path;
debug_decl(set_cmnd, SUDOERS_DEBUG_PLUGIN)
path = def_secure_path;
if (!set_perms(PERM_RUNAS))
debug_return_int(-1);
- rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
+ ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot, NULL);
if (!restore_perms())
debug_return_int(-1);
- if (rval == NOT_FOUND) {
+ if (ret == NOT_FOUND) {
/* Failed as root, try as invoking user. */
if (!set_perms(PERM_USER))
debug_return_int(-1);
- rval = find_path(NewArgv[0], &user_cmnd, user_stat, path,
+ ret = find_path(NewArgv[0], &user_cmnd, user_stat, path,
def_ignore_dot, NULL);
if (!restore_perms())
debug_return_int(-1);
}
- if (rval == NOT_FOUND_ERROR) {
+ if (ret == NOT_FOUND_ERROR) {
if (errno == ENAMETOOLONG)
audit_failure(NewArgc, NewArgv, N_("command too long"));
log_warning(0, "%s", NewArgv[0]);
- debug_return_int(rval);
+ debug_return_int(ret);
}
}
N_("problem with defaults entries"));
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
{
const int errflags = SLOG_RAW_MSG;
login_cap_t *lc;
- bool rval = true;
+ bool ret = true;
debug_decl(set_loginclass, SUDOERS_DEBUG_PLUGIN)
if (!def_use_loginclass)
if (login_class && strcmp(login_class, "-") != 0) {
if (user_uid != 0 && pw->pw_uid != 0) {
sudo_warnx(U_("only root can use `-c %s'"), login_class);
- rval = false;
+ ret = false;
goto done;
}
} else {
log_warningx(errflags, N_("unknown login class: %s"), login_class);
def_use_loginclass = false;
if (login_class)
- rval = false;
+ ret = false;
}
login_close(lc);
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#else
static bool
create_admin_success_flag(void)
{
char flagfile[PATH_MAX];
- int len, rval = -1;
+ int len, ret = -1;
debug_decl(create_admin_success_flag, SUDOERS_DEBUG_PLUGIN)
/* Check whether the user is in the sudo or admin group. */
/* Create admin flag file if it doesn't already exist. */
if (set_perms(PERM_USER)) {
int fd = open(flagfile, O_CREAT|O_WRONLY|O_NONBLOCK|O_EXCL, 0644);
- rval = fd != -1 || errno == EEXIST;
+ ret = fd != -1 || errno == EEXIST;
if (fd != -1)
close(fd);
if (!restore_perms())
- rval = -1;
+ ret = -1;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
#else /* !USE_ADMIN_FLAG */
static int
char idbuf[7], *idstr, *cp;
const char *timestr;
struct log_info *li;
- int rval = -1;
+ int ret = -1;
debug_decl(list_session, SUDO_DEBUG_UTIL)
if ((li = parse_logfile(logfile)) == NULL)
printf("GROUP=%s ; ", li->runas_group);
printf("TSID=%s ; COMMAND=%s\n", idstr, li->cmd);
- rval = 0;
+ ret = 0;
done:
free_log_info(li);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
struct stat sb;
gid_t parent_gid = 0;
char *slash = path;
- bool rval = false;
+ bool ret = false;
debug_decl(ts_mkdirs, SUDOERS_DEBUG_AUTH)
while ((slash = strchr(slash + 1, '/')) != NULL) {
goto done;
}
ignore_result(chown(path, owner, parent_gid));
- rval = true;
+ ret = true;
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
ts_secure_dir(char *path, bool make_it, bool quiet)
{
struct stat sb;
- bool rval = false;
+ bool ret = false;
debug_decl(ts_secure_dir, SUDOERS_DEBUG_AUTH)
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO, "checking %s", path);
switch (sudo_secure_dir(path, timestamp_uid, -1, &sb)) {
case SUDO_PATH_SECURE:
- rval = true;
+ ret = true;
break;
case SUDO_PATH_MISSING:
if (make_it && ts_mkdirs(path, timestamp_uid, 0700, 0711, quiet)) {
- rval = true;
+ ret = true;
break;
}
errno = ENOENT;
errno = EACCES;
break;
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
{
struct sigaction sa, saveint, savequit;
sigset_t mask, omask;
- bool rval;
+ bool ret;
debug_decl(timestamp_lock_record, SUDOERS_DEBUG_AUTH)
if (pos >= 0 && lseek(fd, pos, SEEK_SET) == -1) {
sigaddset(&mask, SIGQUIT);
(void) sigprocmask(SIG_UNBLOCK, &mask, &omask);
- rval = sudo_lock_region(fd, SUDO_LOCK, len);
- if (!rval) {
+ ret = sudo_lock_region(fd, SUDO_LOCK, len);
+ if (!ret) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_ERRNO|SUDO_DEBUG_LINENO,
"failed to lock fd %d [%lld, %lld]", fd,
(long long)pos, (long long)len);
(void) sigaction(SIGQUIT, &savequit, NULL);
/* Re-deliver the signal that interrupted the lock, if any. */
- if (!rval && got_signal)
+ if (!ret && got_signal)
kill(getpid(), got_signal);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
static bool
timestamp_update(void *vcookie, struct passwd *pw)
{
struct ts_cookie *cookie = vcookie;
- int rval = false;
+ int ret = false;
debug_decl(timestamp_update, SUDOERS_DEBUG_AUTH)
/* Zero timeout means don't use time stamp files. */
"writing %zu byte record at %lld", sizeof(cookie->key),
(long long)cookie->pos);
if (ts_write(cookie->fd, cookie->fname, &cookie->key, cookie->pos) != -1)
- rval = true;
+ ret = true;
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
timestamp_remove(bool unlink_it)
{
struct timestamp_entry key, entry;
- int fd = -1, rval = true;
+ int fd = -1, ret = true;
char *fname = NULL;
debug_decl(timestamp_remove, SUDOERS_DEBUG_AUTH)
if (asprintf(&fname, "%s/%s", def_timestampdir, user_name) == -1) {
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- rval = -1;
+ ret = -1;
goto done;
}
/* For "sudo -K" simply unlink the time stamp file. */
if (unlink_it) {
- rval = unlink(fname) ? -1 : true;
+ ret = unlink(fname) ? -1 : true;
goto done;
}
switch (fd) {
case TIMESTAMP_OPEN_ERROR:
if (errno != ENOENT)
- rval = false;
+ ret = false;
goto done;
case TIMESTAMP_PERM_ERROR:
/* Already logged set_perms/restore_perms error. */
- rval = -1;
+ ret = -1;
goto done;
}
/* Lock first record to gain exclusive access. */
if (!timestamp_lock_record(fd, -1, sizeof(struct timestamp_entry))) {
sudo_warn(U_("unable to lock time stamp file %s"), fname);
- rval = -1;
+ ret = -1;
goto done;
}
SET(entry.flags, TS_DISABLED);
if (lseek(fd, 0 - (off_t)sizeof(entry), SEEK_CUR) != -1) {
if (ts_write(fd, fname, &entry, -1) == -1)
- rval = false;
+ ret = false;
}
}
}
if (fd != -1)
close(fd);
free(fname);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
set_lectured(void)
{
char lecture_status[PATH_MAX];
- int len, fd, rval = false;
+ int len, fd, ret = false;
debug_decl(set_lectured, SUDOERS_DEBUG_AUTH)
len = snprintf(lecture_status, sizeof(lecture_status), "%s/%s",
break;
case TIMESTAMP_PERM_ERROR:
/* Already logged set_perms/restore_perms error. */
- rval = -1;
+ ret = -1;
break;
default:
/* Success. */
close(fd);
- rval = true;
+ ret = true;
break;
}
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
struct timespec orig_mtim; /* starting mtime of sudoers file */
off_t orig_size; /* starting size of sudoers file */
struct stat sb; /* stat buffer */
- bool rval = false; /* return value */
+ bool ret = false; /* return value */
debug_decl(edit_sudoers, SUDOERS_DEBUG_UTIL)
if (fstat(sp->fd, &sb) == -1)
else
sudo_warnx(U_("%s unchanged"), sp->tpath);
- rval = true;
+ ret = true;
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
install_sudoers(struct sudoersfile *sp, bool oldperms)
{
struct stat sb;
- bool rval = false;
+ bool ret = false;
debug_decl(install_sudoers, SUDOERS_DEBUG_UTIL)
if (!sp->modified) {
if ((sb.st_mode & 0777) != sudoers_mode)
ignore_result(chmod(sp->path, sudoers_mode));
}
- rval = true;
+ ret = true;
goto done;
}
goto done;
}
}
- rval = true;
+ ret = true;
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/* STUB */
{
struct member *m;
struct alias *a;
- bool rval = true;
+ bool ret = true;
debug_decl(alias_remove_recursive, SUDOERS_DEBUG_ALIAS)
if ((a = alias_remove(name, type)) != NULL) {
TAILQ_FOREACH(m, &a->members, entries) {
if (m->type == ALIAS) {
if (!alias_remove_recursive(m->name, type))
- rval = false;
+ ret = false;
}
}
if (rbinsert(alias_freelist, a, NULL) != 0)
- rval = false;
+ ret = false;
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
static const char *
/*
- * Copyright (c) 2013-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2013-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
export_sudoers(const char *sudoers_path, const char *export_path,
bool quiet, bool strict)
{
- bool rval = false, need_comma = false;
+ bool ret = false, need_comma = false;
const int indent = 4;
FILE *export_fp = stdout;
debug_decl(export_sudoers, SUDOERS_DEBUG_UTIL)
parse_error = true;
errorfile = sudoers_path;
}
- rval = !parse_error;
+ ret = !parse_error;
if (parse_error) {
if (!quiet) {
if (export_fp != NULL) {
(void)fflush(export_fp);
if (ferror(export_fp))
- rval = false;
+ ret = false;
if (export_fp != stdout)
fclose(export_fp);
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
- * Copyright (c) 2010, 2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2010, 2012-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
static int
unsetenv_unhooked(const char *var)
{
- int rval = 0;
+ int ret = 0;
sudo_fn_unsetenv_t fn;
fn = (sudo_fn_unsetenv_t)sudo_dso_findsym(SUDO_DSO_NEXT, "unsetenv");
# ifdef UNSETENV_VOID
fn(var);
# else
- rval = fn(var);
+ ret = fn(var);
# endif
} else {
- rval = rpl_unsetenv(var);
+ ret = rpl_unsetenv(var);
}
- return rval;
+ return ret;
}
#ifdef UNSETENV_VOID
#endif
unsetenv(const char *var)
{
- int rval;
+ int ret;
switch (process_hooks_unsetenv(var)) {
case SUDO_HOOK_RET_STOP:
- rval = 0;
+ ret = 0;
break;
case SUDO_HOOK_RET_ERROR:
- rval = -1;
+ ret = -1;
break;
default:
- rval = unsetenv_unhooked(var);
+ ret = unsetenv_unhooked(var);
break;
}
#ifndef UNSETENV_VOID
- return rval;
+ return ret;
#endif
}
ssize_t nread;
struct sigaction sa;
unsigned char signo = 0;
- int rval = 0;
+ int ret = 0;
debug_decl(dispatch_pending_signals, SUDO_DEBUG_EXEC)
for (;;) {
strerror(errno));
cstat->type = CMD_ERRNO;
cstat->val = errno;
- rval = 1;
+ ret = 1;
break;
}
/* Take the first terminal signal. */
if (signo == SIGINT || signo == SIGQUIT) {
cstat->type = CMD_WSTATUS;
cstat->val = signo + 128;
- rval = 1;
+ ret = 1;
break;
}
}
sudo_warn("kill(%d, SIGTSTP)", (int)getpid());
/* No need to reinstall SIGTSTP handler. */
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
int
pipe_nonblock(int fds[2])
{
- int flags, rval;
+ int flags, ret;
debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC)
- rval = pipe(fds);
- if (rval != -1) {
+ ret = pipe(fds);
+ if (ret != -1) {
flags = fcntl(fds[0], F_GETFL, 0);
if (flags != -1 && !ISSET(flags, O_NONBLOCK))
- rval = fcntl(fds[0], F_SETFL, flags | O_NONBLOCK);
- if (rval != -1) {
+ ret = fcntl(fds[0], F_SETFL, flags | O_NONBLOCK);
+ if (ret != -1) {
flags = fcntl(fds[1], F_GETFL, 0);
if (flags != -1 && !ISSET(flags, O_NONBLOCK))
- rval = fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);
+ ret = fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);
}
- if (rval == -1) {
+ if (ret == -1) {
close(fds[0]);
close(fds[1]);
}
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
{
struct plugin_container *plugin;
sigset_t omask;
- bool rval = true;
+ bool ret = true;
debug_decl(log_ttyin, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
sudo_debug_set_active_instance(sudo_debug_instance);
sigprocmask(SIG_SETMASK, &omask, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/* Call I/O plugin stdin log method. */
{
struct plugin_container *plugin;
sigset_t omask;
- bool rval = true;
+ bool ret = true;
debug_decl(log_stdin, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
sudo_debug_set_active_instance(sudo_debug_instance);
sigprocmask(SIG_SETMASK, &omask, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/* Call I/O plugin tty output log method. */
{
struct plugin_container *plugin;
sigset_t omask;
- bool rval = true;
+ bool ret = true;
debug_decl(log_ttyout, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
}
}
sudo_debug_set_active_instance(sudo_debug_instance);
- if (!rval) {
+ if (!ret) {
/*
* I/O plugin rejected the output, delete the write event
* (user's tty) so we do not display the rejected output.
}
sigprocmask(SIG_SETMASK, &omask, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/* Call I/O plugin stdout log method. */
{
struct plugin_container *plugin;
sigset_t omask;
- bool rval = true;
+ bool ret = true;
debug_decl(log_stdout, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
}
}
sudo_debug_set_active_instance(sudo_debug_instance);
- if (!rval) {
+ if (!ret) {
/*
* I/O plugin rejected the output, delete the write event
* (user's stdout) so we do not display the rejected output.
}
sigprocmask(SIG_SETMASK, &omask, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/* Call I/O plugin stderr log method. */
{
struct plugin_container *plugin;
sigset_t omask;
- bool rval = true;
+ bool ret = true;
debug_decl(log_stderr, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
}
}
sudo_debug_set_active_instance(sudo_debug_instance);
- if (!rval) {
+ if (!ret) {
/*
* I/O plugin rejected the output, delete the write event
* (user's stderr) so we do not display the rejected output.
}
sigprocmask(SIG_SETMASK, &omask, NULL);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
{
char signame[SIG2STR_MAX];
sigaction_t sa, osa;
- int rval = 0;
+ int ret = 0;
debug_decl(suspend_parent, SUDO_DEBUG_EXEC);
switch (signo) {
if (sudo_term_raw(io_fds[SFD_USERTTY], 0))
ttymode = TERM_RAW;
}
- rval = SIGCONT_FG; /* resume command in foreground */
+ ret = SIGCONT_FG; /* resume command in foreground */
break;
}
/* FALLTHROUGH */
if (sudo_sigaction(signo, &osa, NULL) != 0)
sudo_warn(U_("unable to restore handler for signal %d"), signo);
}
- rval = ttymode == TERM_RAW ? SIGCONT_FG : SIGCONT_BG;
+ ret = ttymode == TERM_RAW ? SIGCONT_FG : SIGCONT_BG;
break;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
/*
- * Copyright (c) 2009-2012, 2014-2015
+ * Copyright (c) 2009-2012, 2014-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
{
struct group *gr;
gid_t ttygid = -1;
- bool rval = false;
+ bool ret = false;
debug_decl(get_pty, SUDO_DEBUG_PTY)
if ((gr = getgrnam("tty")) != NULL)
if (openpty(master, slave, name, NULL, NULL) == 0) {
if (chown(name, ttyuid, ttygid) == 0)
- rval = true;
+ ret = true;
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#elif defined(HAVE__GETPTY)
get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
{
char *line;
- bool rval = false;
+ bool ret = false;
debug_decl(get_pty, SUDO_DEBUG_PTY)
/* IRIX-style dynamic ptys (may fork) */
if (*slave != -1) {
(void) chown(line, ttyuid, -1);
strlcpy(name, line, namesz);
- rval = true;
+ ret = true;
} else {
close(*master);
*master = -1;
}
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#elif defined(HAVE_GRANTPT)
# ifndef HAVE_POSIX_OPENPT
get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
{
char *line;
- bool rval = false;
+ bool ret = false;
debug_decl(get_pty, SUDO_DEBUG_PTY)
*master = posix_openpt(O_RDWR|O_NOCTTY);
# endif
(void) chown(line, ttyuid, -1);
strlcpy(name, line, namesz);
- rval = true;
+ ret = true;
}
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#else /* Old-style BSD ptys */
char *bank, *cp;
struct group *gr;
gid_t ttygid = -1;
- bool rval = false;
+ bool ret = false;
debug_decl(get_pty, SUDO_DEBUG_PTY)
if ((gr = getgrnam("tty")) != NULL)
*slave = open(line, O_RDWR|O_NOCTTY, 0);
if (*slave != -1) {
strlcpy(name, line, namesz);
- rval = true; /* success */
+ ret = true; /* success */
goto done;
}
(void) close(*master);
}
}
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#endif /* HAVE_OPENPTY */
/*
- * Copyright (c) 2012-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2012-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
int
register_hook(struct sudo_hook *hook)
{
- int rval;
+ int ret;
debug_decl(register_hook, SUDO_DEBUG_HOOKS)
if (SUDO_API_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
/* Major versions must match. */
errno = EINVAL;
- rval = -1;
+ ret = -1;
} else {
switch (hook->hook_type) {
case SUDO_HOOK_GETENV:
- rval = register_hook_internal(&sudo_hook_getenv_list,
+ ret = register_hook_internal(&sudo_hook_getenv_list,
hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_PUTENV:
- rval = register_hook_internal(&sudo_hook_putenv_list,
+ ret = register_hook_internal(&sudo_hook_putenv_list,
hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_SETENV:
- rval = register_hook_internal(&sudo_hook_setenv_list,
+ ret = register_hook_internal(&sudo_hook_setenv_list,
hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_UNSETENV:
- rval = register_hook_internal(&sudo_hook_unsetenv_list,
+ ret = register_hook_internal(&sudo_hook_unsetenv_list,
hook->hook_fn, hook->closure);
break;
default:
/* XXX - use define for unknown value */
errno = ENOTSUP;
- rval = 1;
+ ret = 1;
break;
}
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/* Hook deregistration internals. */
int
deregister_hook(struct sudo_hook *hook)
{
- int rval = 0;
+ int ret = 0;
debug_decl(deregister_hook, SUDO_DEBUG_HOOKS)
if (SUDO_API_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
/* Major versions must match. */
- rval = -1;
+ ret = -1;
} else {
switch (hook->hook_type) {
case SUDO_HOOK_GETENV:
break;
default:
/* XXX - use define for unknown value */
- rval = 1;
+ ret = 1;
break;
}
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
- * Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2009-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize)
{
struct stat sb;
- bool rval = false;
+ bool ret = false;
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN)
if (sudo_stat_plugin(info, fullpath, pathsize, &sb) != 0) {
sudo_warnx(U_("%s must be only be writable by owner"), fullpath);
goto done;
}
- rval = true;
+ ret = true;
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#else
static bool
struct plugin_container *container;
struct plugin_info_list *plugins;
struct plugin_info *info, *next;
- bool rval = false;
+ bool ret = false;
debug_decl(sudo_load_plugins, SUDO_DEBUG_PLUGIN)
/* Walk the plugin list from sudo.conf, if any and free it. */
plugins = sudo_conf_plugins();
TAILQ_FOREACH_SAFE(info, plugins, entries, next) {
- rval = sudo_load_plugin(policy_plugin, io_plugins, info);
- if (!rval)
+ ret = sudo_load_plugin(policy_plugin, io_plugins, info);
+ if (!ret)
goto done;
free_plugin_info(info);
}
info->symbol_name = "sudoers_policy";
info->path = SUDOERS_PLUGIN;
/* info->options = NULL; */
- rval = sudo_load_plugin(policy_plugin, io_plugins, info);
+ ret = sudo_load_plugin(policy_plugin, io_plugins, info);
free(info);
- if (!rval)
+ if (!ret)
goto done;
/* Default I/O plugin */
info->symbol_name = "sudoers_io";
info->path = SUDOERS_PLUGIN;
/* info->options = NULL; */
- rval = sudo_load_plugin(policy_plugin, io_plugins, info);
+ ret = sudo_load_plugin(policy_plugin, io_plugins, info);
free(info);
- if (!rval)
+ if (!ret)
goto done;
}
}
if (policy_plugin->u.policy->check_policy == NULL) {
sudo_warnx(U_("policy plugin %s does not include a check_policy method"),
policy_plugin->name);
- rval = false;
+ ret = false;
goto done;
}
sudo_debug_set_active_instance(sudo_debug_instance);
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
- * Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2013-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
{
char *tty_libc = NULL, *tty_sudo = NULL;
char pathbuf[PATH_MAX];
- int rval = 1;
+ int ret = 1;
initprogname(argc > 0 ? argv[0] : "check_ttyname");
/* Compare libc and kernel ttys. */
if (tty_libc != NULL && tty_sudo != NULL) {
if (strcmp(tty_libc, tty_sudo) == 0)
- rval = 0;
+ ret = 0;
} else if (tty_libc == NULL && tty_sudo == NULL) {
- rval = 0;
+ ret = 0;
}
- if (rval == 0) {
+ if (ret == 0) {
printf("%s: OK (%s)\n", getprogname(), tty_sudo ? tty_sudo : "none");
} else if (tty_libc == NULL) {
printf("%s: SKIP (%s)\n", getprogname(), tty_sudo ? tty_sudo : "none");
- rval = 0;
+ ret = 0;
} else {
printf("%s: FAIL %s (sudo) vs. %s (libc)\n", getprogname(),
tty_sudo ? tty_sudo : "none", tty_libc ? tty_libc : "none");
}
- exit(rval);
+ return ret;
}
selinux_setup(const char *role, const char *type, const char *ttyn,
int ptyfd)
{
- int rval = -1;
+ int ret = -1;
debug_decl(selinux_setup, SUDO_DEBUG_SELINUX)
/* Store the caller's SID in old_context. */
se_state.ttyn, 1);
#endif
- rval = 0;
+ ret = 0;
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
void
/*
- * Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2009-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
sudo_sigaction(int signo, struct sigaction *sa, struct sigaction *osa)
{
struct signal_state *ss;
- int rval;
+ int ret;
debug_decl(sudo_sigaction, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo > 0; ss++) {
break;
}
}
- rval = sigaction(signo, sa, osa);
+ ret = sigaction(signo, sa, osa);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
fill_group_list(struct user_details *ud, int system_maxgroups)
{
- int tries, rval = -1;
+ int tries, ret = -1;
debug_decl(fill_group_list, SUDO_DEBUG_UTIL)
/*
}
/* No error on insufficient space if user specified max_groups. */
(void)getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
- rval = 0;
+ ret = 0;
} else {
/*
* It is possible to belong to more groups in the group database
*/
ud->groups = NULL;
ud->ngroups = system_maxgroups << 1;
- for (tries = 0; tries < 10 && rval == -1; tries++) {
+ for (tries = 0; tries < 10 && ret == -1; tries++) {
ud->ngroups <<= 1;
free(ud->groups);
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
- rval = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
+ ret = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
}
}
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
static char *
static bool
set_user_groups(struct command_details *details)
{
- bool rval = false;
+ bool ret = false;
debug_decl(set_user_groups, SUDO_DEBUG_EXEC)
if (!ISSET(details->flags, CD_PRESERVE_GROUPS)) {
(unsigned int)details->gid);
goto done;
}
- rval = true;
+ ret = true;
done:
CLR(details->flags, CD_SET_GROUPS);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
bool
exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
{
- bool rval = false;
+ bool ret = false;
debug_decl(exec_setup, SUDO_DEBUG_EXEC)
#ifdef HAVE_SELINUX
}
}
- rval = true;
+ ret = true;
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
/*
char * const user_info[], char * const user_env[])
{
char **plugin_settings;
- int rval;
+ int ret;
debug_decl(policy_open, SUDO_DEBUG_PCOMM)
/* Convert struct sudo_settings to plugin_settings[] */
switch (plugin->u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
case SUDO_API_MKVERSION(1, 1):
- rval = plugin->u.policy_1_0->open(plugin->u.io_1_0->version,
+ ret = plugin->u.policy_1_0->open(plugin->u.io_1_0->version,
sudo_conversation_1_7, sudo_conversation_printf, plugin_settings,
user_info, user_env);
break;
default:
- rval = plugin->u.policy->open(SUDO_API_VERSION, sudo_conversation,
+ ret = plugin->u.policy->open(SUDO_API_VERSION, sudo_conversation,
sudo_conversation_printf, plugin_settings, user_info, user_env,
plugin->options);
}
plugin->debug_instance = sudo_debug_get_active_instance();
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static void
static int
policy_show_version(struct plugin_container *plugin, int verbose)
{
- int rval;
+ int ret;
debug_decl(policy_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->show_version == NULL)
debug_return_int(true);
sudo_debug_set_active_instance(plugin->debug_instance);
- rval = plugin->u.policy->show_version(verbose);
+ ret = plugin->u.policy->show_version(verbose);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
char *env_add[], char **command_info[], char **argv_out[],
char **user_env_out[])
{
- int rval;
+ int ret;
debug_decl(policy_check, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->check_policy == NULL) {
plugin->name);
}
sudo_debug_set_active_instance(plugin->debug_instance);
- rval = plugin->u.policy->check_policy(argc, argv, env_add, command_info,
+ ret = plugin->u.policy->check_policy(argc, argv, env_add, command_info,
argv_out, user_env_out);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
policy_list(struct plugin_container *plugin, int argc, char * const argv[],
int verbose, const char *list_user)
{
- int rval;
+ int ret;
debug_decl(policy_list, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->list == NULL) {
debug_return_int(false);
}
sudo_debug_set_active_instance(plugin->debug_instance);
- rval = plugin->u.policy->list(argc, argv, verbose, list_user);
+ ret = plugin->u.policy->list(argc, argv, verbose, list_user);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
policy_validate(struct plugin_container *plugin)
{
- int rval;
+ int ret;
debug_decl(policy_validate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->validate == NULL) {
debug_return_int(false);
}
sudo_debug_set_active_instance(plugin->debug_instance);
- rval = plugin->u.policy->validate();
+ ret = plugin->u.policy->validate();
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static void
int
policy_init_session(struct command_details *details)
{
- int rval = true;
+ int ret = true;
debug_decl(policy_init_session, SUDO_DEBUG_PCOMM)
/*
switch (policy_plugin.u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
case SUDO_API_MKVERSION(1, 1):
- rval = policy_plugin.u.policy_1_0->init_session(details->pw);
+ ret = policy_plugin.u.policy_1_0->init_session(details->pw);
break;
default:
- rval = policy_plugin.u.policy->init_session(details->pw,
+ ret = policy_plugin.u.policy->init_session(details->pw,
&details->envp);
}
sudo_debug_set_active_instance(sudo_debug_instance);
}
done:
- debug_return_int(rval);
+ debug_return_int(ret);
}
static int
int argc, char * const argv[], char * const user_env[])
{
char **plugin_settings;
- int rval;
+ int ret;
debug_decl(iolog_open, SUDO_DEBUG_PCOMM)
/* Convert struct sudo_settings to plugin_settings[] */
sudo_debug_set_active_instance(plugin->debug_instance);
switch (plugin->u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
- rval = plugin->u.io_1_0->open(plugin->u.io_1_0->version,
+ ret = plugin->u.io_1_0->open(plugin->u.io_1_0->version,
sudo_conversation_1_7, sudo_conversation_printf, plugin_settings,
user_info, argc, argv, user_env);
break;
case SUDO_API_MKVERSION(1, 1):
- rval = plugin->u.io_1_1->open(plugin->u.io_1_1->version,
+ ret = plugin->u.io_1_1->open(plugin->u.io_1_1->version,
sudo_conversation_1_7, sudo_conversation_printf, plugin_settings,
user_info, command_info, argc, argv, user_env);
break;
default:
- rval = plugin->u.io->open(SUDO_API_VERSION, sudo_conversation,
+ ret = plugin->u.io->open(SUDO_API_VERSION, sudo_conversation,
sudo_conversation_printf, plugin_settings, user_info, command_info,
argc, argv, user_env, plugin->options);
}
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
static void
static int
iolog_show_version(struct plugin_container *plugin, int verbose)
{
- int rval;
+ int ret;
debug_decl(iolog_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.io->show_version == NULL)
debug_return_int(true);
sudo_debug_set_active_instance(plugin->debug_instance);
- rval = plugin->u.io->show_version(verbose);
+ ret = plugin->u.io->show_version(verbose);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
struct tempfile *tf, int nfiles, struct timespec *times)
{
char **sesh_args, **sesh_ap;
- int i, rc, sesh_nargs, rval = 1;
+ int i, rc, sesh_nargs, ret = 1;
struct command_details saved_command_details;
struct timespec ts;
struct stat sb;
rc = run_command(command_details);
switch (rc) {
case SESH_SUCCESS:
- rval = 0;
+ ret = 0;
break;
case SESH_ERR_NO_FILES:
sudo_warnx(_("unable to copy temporary files back to their original location"));
command_details->flags = saved_command_details.flags;
command_details->argv = saved_command_details.argv;
- debug_return_int(rval);
+ debug_return_int(ret);
}
#endif /* HAVE_SELINUX */
{
struct command_details saved_command_details;
char **nargv = NULL, **ap, **files = NULL;
- int errors, i, ac, nargc, rval;
+ int errors, i, ac, nargc, rc;
int editor_argc = 0, nfiles = 0;
struct timespec times[2];
struct tempfile *tf = NULL;
command_details->ngroups = user_details.ngroups;
command_details->groups = user_details.groups;
command_details->argv = nargv;
- rval = run_command(command_details);
+ rc = run_command(command_details);
if (sudo_gettime_real(×[1]) == -1) {
sudo_warn(U_("unable to read the clock"));
goto cleanup;
free(tf[i].tfile);
free(tf);
free(nargv);
- debug_return_int(errors ? 1 : rval);
+ debug_return_int(errors ? 1 : rc);
cleanup:
/* Clean up temp files and return. */
/*
- * Copyright (c) 1996, 1998-2005, 2007-2015
+ * Copyright (c) 1996, 1998-2005, 2007-2016
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
static int
suspend(int signo, struct sudo_conv_callback *callback)
{
- int rval = 0;
+ int ret = 0;
debug_decl(suspend, SUDO_DEBUG_CONV)
if (callback != NULL && SUDO_API_VERSION_GET_MAJOR(callback->version) != SUDO_CONV_CALLBACK_VERSION_MAJOR) {
if (callback != NULL && callback->on_suspend != NULL) {
if (callback->on_suspend(signo, callback->closure) == -1)
- rval = -1;
+ ret = -1;
}
kill(getpid(), signo);
if (callback != NULL && callback->on_resume != NULL) {
if (callback->on_resume(signo, callback->closure) == -1)
- rval = -1;
+ ret = -1;
}
- debug_return_int(rval);
+ debug_return_int(ret);
}
/*
{
size_t sdlen, num_subdirs = 0, max_subdirs = 0;
char pathbuf[PATH_MAX], **subdirs = NULL;
- char *rval = NULL;
+ char *ret = NULL;
struct dirent *dp;
unsigned int i;
DIR *d = NULL;
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"resolved dev %u as %s", (unsigned int)rdev, pathbuf);
if (strlcpy(name, pathbuf, namelen) < namelen) {
- rval = name;
+ ret = name;
} else {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"unable to store %s, have %zu, need %zu",
}
/* Search subdirs if we didn't find it in the root level. */
- for (i = 0; rval == NULL && i < num_subdirs; i++)
- rval = sudo_ttyname_scan(subdirs[i], rdev, false, name, namelen);
+ for (i = 0; ret == NULL && i < num_subdirs; i++)
+ ret = sudo_ttyname_scan(subdirs[i], rdev, false, name, namelen);
done:
if (d != NULL)
for (i = 0; i < num_subdirs; i++)
free(subdirs[i]);
free(subdirs);
- debug_return_str(rval);
+ debug_return_str(ret);
}
/*
sudo_ttyname_dev(dev_t rdev, char *name, size_t namelen)
{
char buf[PATH_MAX], **sd, *devname;
- char *rval = NULL;
+ char *ret = NULL;
struct stat sb;
size_t len;
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL)
"comparing dev %u to %s: match!",
(unsigned int)rdev, buf);
if (strlcpy(name, buf, namelen) < namelen)
- rval = name;
+ ret = name;
else
errno = ERANGE;
goto done;
"comparing dev %u to %s: no", (unsigned int)rdev, buf);
} else {
/* Traverse directory */
- rval = sudo_ttyname_scan(devname, rdev, true, name, namelen);
- if (rval != NULL || errno == ENOMEM)
+ ret = sudo_ttyname_scan(devname, rdev, true, name, namelen);
+ if (ret != NULL || errno == ENOMEM)
goto done;
}
} else {
if (stat(devname, &sb) == 0) {
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
if (strlcpy(name, devname, namelen) < namelen)
- rval = name;
+ ret = name;
else
errno = ERANGE;
goto done;
/*
* Not found? Do a breadth-first traversal of /dev/.
*/
- rval = sudo_ttyname_scan(_PATH_DEV, rdev, false, name, namelen);
+ ret = sudo_ttyname_scan(_PATH_DEV, rdev, false, name, namelen);
done:
- debug_return_str(rval);
+ debug_return_str(ret);
}
#endif
struct sudo_kinfo_proc *ki_proc = NULL;
size_t size = sizeof(*ki_proc);
int mib[6], rc, serrno = errno;
- char *rval = NULL;
+ char *ret = NULL;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
/*
if (rc != -1) {
if ((dev_t)ki_proc->sudo_kp_tdev != (dev_t)-1) {
errno = serrno;
- rval = sudo_ttyname_dev(ki_proc->sudo_kp_tdev, name, namelen);
- if (rval == NULL) {
+ ret = sudo_ttyname_dev(ki_proc->sudo_kp_tdev, name, namelen);
+ if (ret == NULL) {
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"unable to map device number %u to name",
ki_proc->sudo_kp_tdev);
}
free(ki_proc);
- debug_return_str(rval);
+ debug_return_str(ret);
}
#elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV)
/*
char *
get_process_ttyname(char *name, size_t namelen)
{
- char path[PATH_MAX], *rval = NULL;
+ char path[PATH_MAX], *ret = NULL;
struct psinfo psinfo;
ssize_t nread;
int fd, serrno = errno;
#endif
if (rdev != (dev_t)-1) {
errno = serrno;
- rval = sudo_ttyname_dev(rdev, name, namelen);
+ ret = sudo_ttyname_dev(rdev, name, namelen);
goto done;
}
}
errno = ENOENT;
done:
- if (rval == NULL)
+ if (ret == NULL)
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"unable to resolve tty via %s", path);
- debug_return_str(rval);
+ debug_return_str(ret);
}
#elif defined(__linux__)
/*
get_process_ttyname(char *name, size_t namelen)
{
char path[PATH_MAX], *line = NULL;
- char *rval = NULL;
+ char *ret = NULL;
size_t linesize = 0;
int serrno = errno;
ssize_t len;
}
if (tdev > 0) {
errno = serrno;
- rval = sudo_ttyname_dev(tdev, name, namelen);
+ ret = sudo_ttyname_dev(tdev, name, namelen);
goto done;
}
break;
done:
free(line);
- if (rval == NULL)
+ if (ret == NULL)
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"unable to resolve tty via %s", path);
- debug_return_str(rval);
+ debug_return_str(ret);
}
#elif defined(HAVE_PSTAT_GETPROC)
/*
get_process_ttyname(char *name, size_t namelen)
{
struct pst_status pstat;
- char *rval = NULL;
+ char *ret = NULL;
int rc, serrno = errno;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
if (rc != -1 || errno == EOVERFLOW) {
if (pstat.pst_term.psd_major != -1 && pstat.pst_term.psd_minor != -1) {
errno = serrno;
- rval = sudo_ttyname_dev(makedev(pstat.pst_term.psd_major,
+ ret = sudo_ttyname_dev(makedev(pstat.pst_term.psd_major,
pstat.pst_term.psd_minor), name, namelen);
goto done;
}
errno = ENOENT;
done:
- if (rval == NULL)
+ if (ret == NULL)
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"unable to resolve tty via pstat");
- debug_return_str(rval);
+ debug_return_str(ret);
}
#else
/*
/*
- * Copyright (c) 2011-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2011-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
const char *user)
{
sudo_utmp_t utbuf, *ut_old = NULL;
- bool rval = false;
+ bool ret = false;
debug_decl(utmp_login, SUDO_DEBUG_UTMP)
/* Strip off /dev/ prefix from line as needed. */
}
utmp_fill(to_line, user, ut_old, &utbuf);
if (pututxline(&utbuf) != NULL)
- rval = true;
+ ret = true;
endutxent();
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
bool
utmp_logout(const char *line, int status)
{
- bool rval = false;
+ bool ret = false;
sudo_utmp_t *ut, utbuf;
debug_decl(utmp_logout, SUDO_DEBUG_UTMP)
# endif
utmp_settime(ut);
if (pututxline(ut) != NULL)
- rval = true;
+ ret = true;
}
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#else /* !HAVE_GETUTXID && !HAVE_GETUTID */
const char *user)
{
sudo_utmp_t utbuf, *ut_old = NULL;
- bool rval = false;
+ bool ret = false;
int slot;
FILE *fp;
debug_decl(utmp_login, SUDO_DEBUG_UTMP)
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) {
#endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
- rval = true;
+ ret = true;
}
fclose(fp);
done:
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
bool
utmp_logout(const char *line, int status)
{
sudo_utmp_t utbuf;
- bool rval = false;
+ bool ret = false;
FILE *fp;
debug_decl(utmp_logout, SUDO_DEBUG_UTMP)
if ((fp = fopen(_PATH_UTMP, "r+")) == NULL)
- debug_return_int(rval);
+ debug_return_int(ret);
/* Strip off /dev/ prefix from line as needed. */
if (strncmp(line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) {
#endif
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
- rval = true;
+ ret = true;
}
break;
}
}
fclose(fp);
- debug_return_bool(rval);
+ debug_return_bool(ret);
}
#endif /* HAVE_GETUTXID || HAVE_GETUTID */