From: Todd C. Miller Date: Thu, 8 Sep 2016 22:38:08 +0000 (-0600) Subject: Be consistent with the naming of the variable used to store the X-Git-Tag: SUDO_1_8_18^2~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f022419ae26fae464a3783eb91024f5f65bd4d3;p=sudo Be consistent with the naming of the variable used to store the function return value. Previously, some code used "rval", some used "ret". This standardizes on "ret" and uses "rc" for temporary return codes. --- diff --git a/include/sudo_debug.h b/include/sudo_debug.h index ba151d1bc..353a8257b 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Todd C. Miller + * Copyright (c) 2011-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -121,84 +121,84 @@ struct sudo_conf_debug_file_list; 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) /* @@ -227,14 +227,14 @@ __dso_public int sudo_debug_deregister_v1(int instance_id); __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); diff --git a/lib/util/aix.c b/lib/util/aix.c index 180ff5c6b..7c1586dbc 100644 --- a/lib/util/aix.c +++ b/lib/util/aix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010-2015 Todd C. Miller + * Copyright (c) 2008, 2010-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -155,13 +155,13 @@ int usrinfo(int cmd, char *buf, int count); * 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'; @@ -172,8 +172,8 @@ aix_getauthregistry_v1(char *user, char *saved_registry) 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, @@ -186,11 +186,11 @@ aix_getauthregistry_v1(char *user, char *saved_registry) 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); } /* @@ -199,7 +199,7 @@ done: * 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) @@ -212,7 +212,7 @@ aix_setauthdb_v2(char *user, char *registry) { authdb_t regbuf; int serrno = errno; - int rval = -1; + int ret = -1; debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL) if (user != NULL) { @@ -222,8 +222,8 @@ aix_setauthdb_v2(char *user, char *registry) 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 { @@ -234,30 +234,30 @@ aix_setauthdb_v2(char *user, char *registry) } 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 diff --git a/lib/util/fnmatch.c b/lib/util/fnmatch.c index 9337db28a..84bc2cfc7 100644 --- a/lib/util/fnmatch.c +++ b/lib/util/fnmatch.c @@ -114,7 +114,7 @@ classmatch(const char *pattern, char test, int foldcase, const char **ep) 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] != ':') { @@ -135,16 +135,16 @@ classmatch(const char *pattern, char test, int foldcase, const char **ep) 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. diff --git a/lib/util/getgrouplist.c b/lib/util/getgrouplist.c index 3d1069a4b..8ab3cfb63 100644 --- a/lib/util/getgrouplist.c +++ b/lib/util/getgrouplist.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2011, 2013, 2014 + * Copyright (c) 2010, 2011, 2013-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -53,7 +53,7 @@ sudo_getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp) 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 */ @@ -77,7 +77,7 @@ sudo_getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp) } } } - rval = 0; + ret = 0; done: free(grset); @@ -86,7 +86,7 @@ done: #endif *ngroupsp = ngroups; - return rval; + return ret; } #elif defined(HAVE_NSS_SEARCH) @@ -196,7 +196,7 @@ static nss_status_t 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; @@ -229,7 +229,7 @@ process_cstr(const char *instr, int inlen, struct nss_groupsbymem *gbm) } done: _nss_XbyY_buf_free(buf); - return rval; + return ret; } /* @@ -279,7 +279,7 @@ sudo_getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp) { 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 */ @@ -310,13 +310,13 @@ sudo_getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroupsp) 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 */ diff --git a/lib/util/secure_path.c b/lib/util/secure_path.c index aba7d30e8..7205f43e1 100644 --- a/lib/util/secure_path.c +++ b/lib/util/secure_path.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014-2015 Todd C. Miller + * Copyright (c) 2012, 2014-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -39,27 +39,27 @@ static int 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); } /* diff --git a/lib/util/setgroups.c b/lib/util/setgroups.c index f6978427f..ce25a1c38 100644 --- a/lib/util/setgroups.c +++ b/lib/util/setgroups.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2012, 2014-2015 Todd C. Miller + * Copyright (c) 2011-2012, 2014-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -33,17 +33,17 @@ 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); } diff --git a/lib/util/strtoid.c b/lib/util/strtoid.c index a38bd3535..c70925f0d 100644 --- a/lib/util/strtoid.c +++ b/lib/util/strtoid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015 Todd C. Miller + * Copyright (c) 2013-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -52,7 +52,7 @@ id_t 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) @@ -89,7 +89,7 @@ sudo_strtoid_v1(const char *p, const char *sep, char **endp, const char **errstr *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) { @@ -111,12 +111,12 @@ sudo_strtoid_v1(const char *p, const char *sep, char **endp, const char **errstr *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); } diff --git a/lib/util/sudo_conf.c b/lib/util/sudo_conf.c index 399e70be3..ad00c396c 100644 --- a/lib/util/sudo_conf.c +++ b/lib/util/sudo_conf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 Todd C. Miller + * Copyright (c) 2009-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -154,7 +154,7 @@ static int 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++) { @@ -163,11 +163,11 @@ parse_variable(const char *entry, const char *conf_file, unsigned int lineno) 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", diff --git a/lib/util/sudo_debug.c b/lib/util/sudo_debug.c index 6e04278b9..967a762c9 100644 --- a/lib/util/sudo_debug.c +++ b/lib/util/sudo_debug.c @@ -437,69 +437,69 @@ sudo_debug_exit_v1(const char *func, const char *file, int line, 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 diff --git a/plugins/sample/sample_plugin.c b/plugins/sample/sample_plugin.c index 9e9746a03..f8aebddba 100644 --- a/plugins/sample/sample_plugin.c +++ b/plugins/sample/sample_plugin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Todd C. Miller + * Copyright (c) 2010-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -445,7 +445,7 @@ static int 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)); /* @@ -455,11 +455,11 @@ io_log_output(const char *buf, unsigned int len) */ 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 = { diff --git a/plugins/sudoers/auth/aix_auth.c b/plugins/sudoers/auth/aix_auth.c index bd55dbcf8..a86772b32 100644 --- a/plugins/sudoers/auth/aix_auth.c +++ b/plugins/sudoers/auth/aix_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2005, 2007-2015 Todd C. Miller + * Copyright (c) 1999-2005, 2007-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -140,7 +140,7 @@ sudo_aix_verify(struct passwd *pw, char *prompt, sudo_auth *auth, struct sudo_co { 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 { @@ -168,10 +168,10 @@ sudo_aix_verify(struct passwd *pw, char *prompt, sudo_auth *auth, struct sudo_co 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 diff --git a/plugins/sudoers/auth/securid5.c b/plugins/sudoers/auth/securid5.c index 468eef23f..694236cd8 100644 --- a/plugins/sudoers/auth/securid5.c +++ b/plugins/sudoers/auth/securid5.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2005, 2007, 2010-2012, 2014-2015 + * Copyright (c) 1999-2005, 2007, 2010-2012, 2014-2016 * Todd C. Miller * Copyright (c) 2002 Michael Stroucken * @@ -142,7 +142,7 @@ int 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: ", @@ -151,26 +151,26 @@ sudo_securid_verify(struct passwd *pw, char *pass, sudo_auth *auth, struct sudo_ /* 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: @@ -188,11 +188,11 @@ then enter the new token code.\n", \ 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: @@ -206,12 +206,12 @@ then enter the new token code.\n", \ "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; } @@ -224,7 +224,7 @@ then enter the new token code.\n", \ } /* Return stored state to calling process */ - debug_return_int(rval); + debug_return_int(ret); } #endif /* HAVE_SECURID */ diff --git a/plugins/sudoers/auth/sudo_auth.c b/plugins/sudoers/auth/sudo_auth.c index dca4e1c7c..7fca030f4 100644 --- a/plugins/sudoers/auth/sudo_auth.c +++ b/plugins/sudoers/auth/sudo_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2005, 2008-2015 Todd C. Miller + * Copyright (c) 1999-2005, 2008-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -213,7 +213,7 @@ verify_user(struct passwd *pw, char *prompt, int validated, 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; @@ -311,23 +311,23 @@ done: 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); } /* diff --git a/plugins/sudoers/check.c b/plugins/sudoers/check.c index 0aa9e0357..67cd7bf3b 100644 --- a/plugins/sudoers/check.c +++ b/plugins/sudoers/check.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1993-1996,1998-2005, 2007-2015 + * Copyright (c) 1993-1996,1998-2005, 2007-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -90,7 +90,7 @@ check_user_interactive(int validated, int mode, struct passwd *auth_pw) 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) @@ -124,7 +124,7 @@ check_user_interactive(int validated, int mode, struct passwd *auth_pw) case TS_CURRENT: /* Time stamp file is valid and current. */ if (!ISSET(validated, FLAG_CHECK_USER)) { - rval = true; + ret = true; break; } /* FALLTHROUGH */ @@ -146,8 +146,8 @@ check_user_interactive(int validated, int mode, struct passwd *auth_pw) 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; @@ -157,14 +157,14 @@ check_user_interactive(int validated, int mode, struct passwd *auth_pw) * 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); } /* @@ -175,7 +175,7 @@ int check_user(int validated, int mode) { struct passwd *auth_pw; - int rval = -1; + int ret = -1; debug_decl(check_user, SUDOERS_DEBUG_AUTH) /* @@ -192,7 +192,7 @@ check_user(int validated, int mode) * 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 && @@ -204,18 +204,18 @@ check_user(int validated, int mode) 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); } /* @@ -266,12 +266,12 @@ display_lecture(int status) 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); } /* diff --git a/plugins/sudoers/env.c b/plugins/sudoers/env.c index 764ccf0fa..6be2e5391 100644 --- a/plugins/sudoers/env.c +++ b/plugins/sudoers/env.c @@ -365,19 +365,19 @@ sudo_putenv_nodebug(char *str, bool dupcheck, bool overwrite) 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); } /* @@ -390,7 +390,7 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite) { 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; @@ -408,13 +408,13 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite) 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); } /* @@ -436,7 +436,7 @@ sudo_setenv_nodebug(const char *var, const char *val, int overwrite) char *ep, *estring = NULL; const char *cp; size_t esize; - int rval = -1; + int ret = -1; if (var == NULL || *var == '\0') { errno = EINVAL; @@ -466,13 +466,13 @@ sudo_setenv_nodebug(const char *var, const char *val, int overwrite) } *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; } /* @@ -511,14 +511,14 @@ sudo_unsetenv_nodebug(const char *var) 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); } /* @@ -770,7 +770,7 @@ bool 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++) { @@ -778,11 +778,11 @@ env_merge(char * const envp[]) 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 */ @@ -1092,7 +1092,7 @@ bool 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. */ @@ -1100,12 +1100,12 @@ insert_env_vars(char * const envp[]) 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); } /* @@ -1119,7 +1119,7 @@ validate_env_vars(char * const env_vars[]) { 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) @@ -1154,9 +1154,9 @@ validate_env_vars(char * const env_vars[]) /* 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); } /* @@ -1173,15 +1173,15 @@ bool 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) { @@ -1216,7 +1216,7 @@ read_env_file(const char *path, int overwrite) 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 '=' */ @@ -1225,14 +1225,14 @@ read_env_file(const char *path, int overwrite) 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 diff --git a/plugins/sudoers/goodpath.c b/plugins/sudoers/goodpath.c index 822a03bfc..b992a7a51 100644 --- a/plugins/sudoers/goodpath.c +++ b/plugins/sudoers/goodpath.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2015 + * Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -41,7 +41,7 @@ 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) { @@ -53,11 +53,11 @@ sudo_goodpath(const char *path, struct stat *sbp) 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); } diff --git a/plugins/sudoers/gram.c b/plugins/sudoers/gram.c index aa7117d19..97230fc09 100644 --- a/plugins/sudoers/gram.c +++ b/plugins/sudoers/gram.c @@ -38,7 +38,7 @@ #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 * * Permission to use, copy, modify, and distribute this software for any @@ -688,6 +688,7 @@ short *yyss; short *yysslim; YYSTYPE *yyvs; unsigned int yystacksize; +int yyparse(void); #line 859 "gram.y" void sudoerserror(const char *s) @@ -858,7 +859,7 @@ init_parser(const char *path, bool quiet) 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) { @@ -967,14 +968,14 @@ init_parser(const char *path, bool quiet) 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; @@ -985,9 +986,9 @@ init_parser(const char *path, bool quiet) 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) @@ -2080,7 +2081,7 @@ case 115: } } break; -#line 2031 "gram.c" +#line 2032 "gram.c" } yyssp -= yym; yystate = *yyssp; diff --git a/plugins/sudoers/gram.y b/plugins/sudoers/gram.y index da87b97cc..a1e7819f5 100644 --- a/plugins/sudoers/gram.y +++ b/plugins/sudoers/gram.y @@ -1,6 +1,6 @@ %{ /* - * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2015 + * Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -1025,7 +1025,7 @@ init_parser(const char *path, bool quiet) 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) { @@ -1134,14 +1134,14 @@ init_parser(const char *path, bool quiet) 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; @@ -1152,5 +1152,5 @@ init_parser(const char *path, bool quiet) errorfile = sudoers; sudoers_warnings = !quiet; - debug_return_bool(rval); + debug_return_bool(ret); } diff --git a/plugins/sudoers/interfaces.c b/plugins/sudoers/interfaces.c index fda41669f..583d75ef7 100644 --- a/plugins/sudoers/interfaces.c +++ b/plugins/sudoers/interfaces.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2015 Todd C. Miller + * Copyright (c) 2010-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -54,7 +54,7 @@ set_interfaces(const char *ai) { 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) @@ -93,11 +93,11 @@ set_interfaces(const char *ai) } SLIST_INSERT_HEAD(&interfaces, ifp, entries); } - rval = true; + ret = true; done: free(addrinfo); - debug_return_bool(rval); + debug_return_bool(ret); } struct interface_list * diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 36b233001..99b42d1df 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -204,7 +204,7 @@ io_nextid(char *iolog_dir, char *iolog_dir_fallback, char sessid[7]) 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) @@ -307,12 +307,12 @@ io_nextid(char *iolog_dir, char *iolog_dir_fallback, char sessid[7]) warned = true; goto done; } - rval = true; + ret = true; done: if (fd != -1) close(fd); - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -572,7 +572,7 @@ write_info_log(char *pathbuf, size_t len, struct iolog_details *details, char * const *av; FILE *fp; int fd; - bool rval; + bool ret; debug_decl(write_info_log, SUDOERS_DEBUG_UTIL) pathbuf[len] = '\0'; @@ -596,9 +596,9 @@ write_info_log(char *pathbuf, size_t len, struct iolog_details *details, fputc('\n', fp); fflush(fp); - rval = !ferror(fp); + ret = !ferror(fp); fclose(fp); - debug_return_bool(rval); + debug_return_bool(ret); } static int @@ -613,7 +613,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, 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; @@ -644,7 +644,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, * Pull iolog settings out of command_info. */ if (!iolog_deserialize_info(&iolog_details, user_info, command_info)) { - rval = false; + ret = false; goto done; } @@ -658,7 +658,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, } 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, @@ -700,7 +700,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, if (!io_log_files[IOFD_TTYOUT].enabled) sudoers_io.log_ttyout = NULL; - rval = true; + ret = true; done: free(tofree); @@ -712,10 +712,10 @@ done: 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 @@ -771,7 +771,7 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) { 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) { @@ -788,14 +788,14 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) 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); @@ -806,7 +806,7 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) int errnum; errstr = gzerror(io_log_files[IOFD_TIMING].fd.g, &errnum); - rval = -1; + ret = -1; } } else #endif @@ -814,13 +814,13 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) 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, @@ -830,10 +830,10 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) /* 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 diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index df1402e0a..4b2b0ed37 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -1443,7 +1443,7 @@ sudo_netgroup_lookup(LDAP *ld, struct passwd *pw, 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) { @@ -1573,7 +1573,7 @@ sudo_netgroup_lookup(LDAP *ld, struct passwd *pw, goto done; } } - rval = true; + ret = true; goto done; oom: @@ -1586,7 +1586,7 @@ done: free(escaped_shost); free(filt); ldap_msgfree(result); - debug_return_bool(rval); + debug_return_bool(ret); } /* diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index a21445078..e741f38dc 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994-1996, 1998-2015 Todd C. Miller + * Copyright (c) 1994-1996, 1998-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -146,7 +146,7 @@ do_logfile(const char *msg) static bool warned = false; const char *timestr; int len, oldlocale; - bool rval = false; + bool ret = false; char *full_line; mode_t oldmask; FILE *fp; @@ -206,14 +206,14 @@ do_logfile(const char *msg) } 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); } /* @@ -225,7 +225,7 @@ log_denial(int status, bool inform_user) 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). */ @@ -261,11 +261,11 @@ log_denial(int status, bool inform_user) 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); @@ -298,7 +298,7 @@ log_denial(int status, bool inform_user) } sudoers_setlocale(oldlocale, NULL); } - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -307,14 +307,14 @@ log_denial(int status, bool inform_user) 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) { /* @@ -330,7 +330,7 @@ log_failure(int status, int flags) 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); } /* @@ -340,7 +340,7 @@ bool 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. */ @@ -368,11 +368,11 @@ log_auth_failure(int status, unsigned int tries) * 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); } /* @@ -383,7 +383,7 @@ log_allowed(int status) { 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. */ @@ -405,18 +405,18 @@ log_allowed(int status) 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); } /* @@ -427,7 +427,7 @@ vlog_warning(int flags, const char *fmt, va_list ap) { 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) @@ -448,7 +448,7 @@ vlog_warning(int flags, const char *fmt, va_list ap) } if (len == -1) { sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); - rval = false; + ret = false; goto done; } @@ -467,7 +467,7 @@ vlog_warning(int flags, const char *fmt, va_list ap) 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; } @@ -490,12 +490,12 @@ vlog_warning(int flags, const char *fmt, va_list ap) 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); @@ -522,37 +522,37 @@ done: 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 diff --git a/plugins/sudoers/match.c b/plugins/sudoers/match.c index d405e623e..97f538b0c 100644 --- a/plugins/sudoers/match.c +++ b/plugins/sudoers/match.c @@ -98,7 +98,7 @@ userlist_matches(const struct passwd *pw, const struct member_list *list) { 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) { @@ -118,9 +118,9 @@ userlist_matches(const struct passwd *pw, const struct member_list *list) 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; } @@ -148,7 +148,7 @@ runaslist_matches(const struct member_list *user_list, { 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) @@ -184,10 +184,10 @@ runaslist_matches(const struct member_list *user_list, 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; } @@ -227,10 +227,10 @@ runaslist_matches(const struct member_list *user_list, 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; } @@ -269,7 +269,7 @@ hostlist_matches(const struct passwd *pw, const struct member_list *list) { 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) { @@ -288,9 +288,9 @@ hostlist_matches(const struct passwd *pw, const struct member_list *list) 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; } @@ -334,7 +334,7 @@ cmnd_matches(const struct member *m) { 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) { @@ -343,9 +343,9 @@ cmnd_matches(const struct member *m) 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; @@ -988,7 +988,7 @@ sudo_getdomainname(void) 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); @@ -1000,11 +1000,11 @@ sudo_getdomainname(void) 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++) { diff --git a/plugins/sudoers/parse.c b/plugins/sudoers/parse.c index 0fde088aa..d30d33aa5 100644 --- a/plugins/sudoers/parse.c +++ b/plugins/sudoers/parse.c @@ -741,7 +741,7 @@ sudo_file_display_cmnd(struct sudo_nss *nss, struct passwd *pw) 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) @@ -775,10 +775,10 @@ sudo_file_display_cmnd(struct sudo_nss *nss, struct passwd *pw) 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); } /* diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index 65332e28c..421463238 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -716,7 +716,7 @@ sudoers_policy_check(int argc, char * const argv[], char *env_add[], 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)) @@ -726,14 +726,14 @@ sudoers_policy_check(int argc, char * const argv[], char *env_add[], 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 @@ -764,7 +764,7 @@ 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"; @@ -781,13 +781,13 @@ sudoers_policy_list(int argc, char * const argv[], int verbose, 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 diff --git a/plugins/sudoers/pwutil.c b/plugins/sudoers/pwutil.c index 30551d472..34bbe92f1 100644 --- a/plugins/sudoers/pwutil.c +++ b/plugins/sudoers/pwutil.c @@ -89,10 +89,10 @@ cmp_pwnam(const void *v1, const void *v2) { 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 diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index c4c3dc7f0..ebc6a61f6 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -149,7 +149,7 @@ sudoers_policy_init(void *info, char * const envp[]) { 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); @@ -207,17 +207,17 @@ sudoers_policy_init(void *info, char * const envp[]) /* 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 @@ -230,7 +230,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], 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); @@ -391,7 +391,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], /* 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; } @@ -427,7 +427,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], } goto bad; default: - /* some other error, rval is -1. */ + /* some other error, ret is -1. */ goto done; } @@ -503,18 +503,18 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], 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. */ @@ -530,7 +530,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], group_plugin_unload(); if (ISSET(sudo_mode, (MODE_VALIDATE|MODE_CHECK|MODE_LIST))) { - /* rval already set appropriately */ + /* ret already set appropriately */ goto done; } @@ -619,7 +619,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], } /* 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. */ @@ -628,11 +628,11 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], goto done; bad: - rval = false; + ret = false; done: if (!rewind_perms()) - rval = -1; + ret = -1; restore_nproc(); @@ -642,7 +642,7 @@ done: sudo_warn_set_locale_func(NULL); - debug_return_int(rval); + debug_return_int(ret); } /* @@ -755,7 +755,7 @@ init_vars(char * const envp[]) static int set_cmnd(void) { - int rval = FOUND; + int ret = FOUND; char *path = user_path; debug_decl(set_cmnd, SUDOERS_DEBUG_PLUGIN) @@ -776,24 +776,24 @@ set_cmnd(void) 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); } } @@ -849,7 +849,7 @@ set_cmnd(void) N_("problem with defaults entries")); } - debug_return_int(rval); + debug_return_int(ret); } /* @@ -940,7 +940,7 @@ set_loginclass(struct passwd *pw) { 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) @@ -949,7 +949,7 @@ set_loginclass(struct passwd *pw) 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 { @@ -970,11 +970,11 @@ set_loginclass(struct passwd *pw) 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 @@ -1246,7 +1246,7 @@ static int 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. */ @@ -1263,13 +1263,13 @@ create_admin_success_flag(void) /* 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 diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 9ff014abf..d0b6385c7 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -944,7 +944,7 @@ list_session(char *logfile, regex_t *re, const char *user, const char *tty) 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) @@ -979,11 +979,11 @@ list_session(char *logfile, regex_t *re, const char *user, const char *tty) 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 diff --git a/plugins/sudoers/timestamp.c b/plugins/sudoers/timestamp.c index 05a67aae5..dfdb86d91 100644 --- a/plugins/sudoers/timestamp.c +++ b/plugins/sudoers/timestamp.c @@ -155,7 +155,7 @@ ts_mkdirs(char *path, uid_t owner, mode_t mode, mode_t parent_mode, bool quiet) 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) { @@ -197,9 +197,9 @@ ts_mkdirs(char *path, uid_t owner, mode_t mode, mode_t parent_mode, bool quiet) goto done; } ignore_result(chown(path, owner, parent_gid)); - rval = true; + ret = true; done: - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -212,17 +212,17 @@ static bool 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; @@ -246,7 +246,7 @@ ts_secure_dir(char *path, bool make_it, bool quiet) errno = EACCES; break; } - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -468,7 +468,7 @@ timestamp_lock_record(int fd, off_t pos, off_t len) { 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) { @@ -490,8 +490,8 @@ timestamp_lock_record(int fd, off_t pos, off_t len) 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); @@ -503,10 +503,10 @@ timestamp_lock_record(int fd, off_t pos, off_t 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 @@ -804,7 +804,7 @@ 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. */ @@ -831,10 +831,10 @@ timestamp_update(void *vcookie, struct passwd *pw) "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); } /* @@ -846,19 +846,19 @@ int 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; } @@ -867,17 +867,17 @@ timestamp_remove(bool unlink_it) 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; } @@ -891,7 +891,7 @@ timestamp_remove(bool unlink_it) 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; } } } @@ -900,7 +900,7 @@ done: if (fd != -1) close(fd); free(fname); - debug_return_int(rval); + debug_return_int(ret); } /* @@ -934,7 +934,7 @@ int 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", @@ -957,15 +957,15 @@ set_lectured(void) 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); } diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 3e9ecdce4..a0326b614 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -431,7 +431,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc, 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) @@ -546,9 +546,9 @@ edit_sudoers(struct sudoersfile *sp, char *editor, int editor_argc, else sudo_warnx(U_("%s unchanged"), sp->tpath); - rval = true; + ret = true; done: - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -653,7 +653,7 @@ static bool 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) { @@ -667,7 +667,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms) if ((sb.st_mode & 0777) != sudoers_mode) ignore_result(chmod(sp->path, sudoers_mode)); } - rval = true; + ret = true; goto done; } @@ -740,9 +740,9 @@ install_sudoers(struct sudoersfile *sp, bool oldperms) goto done; } } - rval = true; + ret = true; done: - debug_return_bool(rval); + debug_return_bool(ret); } /* STUB */ @@ -1057,20 +1057,20 @@ alias_remove_recursive(char *name, int type) { 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 * diff --git a/plugins/sudoers/visudo_json.c b/plugins/sudoers/visudo_json.c index 5e83ccf80..584b37802 100644 --- a/plugins/sudoers/visudo_json.c +++ b/plugins/sudoers/visudo_json.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015 Todd C. Miller + * Copyright (c) 2013-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -998,7 +998,7 @@ bool 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) @@ -1032,7 +1032,7 @@ export_sudoers(const char *sudoers_path, const char *export_path, parse_error = true; errorfile = sudoers_path; } - rval = !parse_error; + ret = !parse_error; if (parse_error) { if (!quiet) { @@ -1064,9 +1064,9 @@ done: 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); } diff --git a/src/env_hooks.c b/src/env_hooks.c index d05331d26..00c0cea25 100644 --- a/src/env_hooks.c +++ b/src/env_hooks.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, 2014 Todd C. Miller + * Copyright (c) 2010, 2012-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -250,7 +250,7 @@ typedef int (*sudo_fn_unsetenv_t)(const char *); 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"); @@ -258,12 +258,12 @@ unsetenv_unhooked(const char *var) # 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 @@ -273,20 +273,20 @@ __dso_public int #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 } diff --git a/src/exec.c b/src/exec.c index 7bcada411..56da013c9 100644 --- a/src/exec.c +++ b/src/exec.c @@ -754,7 +754,7 @@ dispatch_pending_signals(struct command_status *cstat) 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 (;;) { @@ -773,14 +773,14 @@ dispatch_pending_signals(struct command_status *cstat) 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; } } @@ -796,7 +796,7 @@ dispatch_pending_signals(struct command_status *cstat) sudo_warn("kill(%d, SIGTSTP)", (int)getpid()); /* No need to reinstall SIGTSTP handler. */ } - debug_return_int(rval); + debug_return_int(ret); } /* @@ -975,24 +975,24 @@ handler_user_only(int s, siginfo_t *info, void *context) 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); } diff --git a/src/exec_pty.c b/src/exec_pty.c index a22bee6cf..8c38a019b 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -203,7 +203,7 @@ log_ttyin(const char *buf, unsigned int n, struct io_buffer *iob) { 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); @@ -225,7 +225,7 @@ log_ttyin(const char *buf, unsigned int n, struct io_buffer *iob) 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. */ @@ -234,7 +234,7 @@ log_stdin(const char *buf, unsigned int n, struct io_buffer *iob) { 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); @@ -256,7 +256,7 @@ log_stdin(const char *buf, unsigned int n, struct io_buffer *iob) 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. */ @@ -265,7 +265,7 @@ log_ttyout(const char *buf, unsigned int n, struct io_buffer *iob) { 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); @@ -285,7 +285,7 @@ log_ttyout(const char *buf, unsigned int n, struct io_buffer *iob) } } 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. @@ -299,7 +299,7 @@ log_ttyout(const char *buf, unsigned int n, struct io_buffer *iob) } sigprocmask(SIG_SETMASK, &omask, NULL); - debug_return_bool(rval); + debug_return_bool(ret); } /* Call I/O plugin stdout log method. */ @@ -308,7 +308,7 @@ log_stdout(const char *buf, unsigned int n, struct io_buffer *iob) { 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); @@ -328,7 +328,7 @@ log_stdout(const char *buf, unsigned int n, struct io_buffer *iob) } } 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. @@ -342,7 +342,7 @@ log_stdout(const char *buf, unsigned int n, struct io_buffer *iob) } sigprocmask(SIG_SETMASK, &omask, NULL); - debug_return_bool(rval); + debug_return_bool(ret); } /* Call I/O plugin stderr log method. */ @@ -351,7 +351,7 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob) { 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); @@ -371,7 +371,7 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob) } } 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. @@ -385,7 +385,7 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob) } sigprocmask(SIG_SETMASK, &omask, NULL); - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -421,7 +421,7 @@ suspend_parent(int signo) { char signame[SIG2STR_MAX]; sigaction_t sa, osa; - int rval = 0; + int ret = 0; debug_decl(suspend_parent, SUDO_DEBUG_EXEC); switch (signo) { @@ -438,7 +438,7 @@ suspend_parent(int 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 */ @@ -495,11 +495,11 @@ suspend_parent(int signo) 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); } /* diff --git a/src/get_pty.c b/src/get_pty.c index 5ecd4cdb2..78ea63dca 100644 --- a/src/get_pty.c +++ b/src/get_pty.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2012, 2014-2015 + * Copyright (c) 2009-2012, 2014-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -54,7 +54,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) { 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) @@ -62,10 +62,10 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) 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) @@ -73,7 +73,7 @@ bool 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) */ @@ -83,13 +83,13 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) 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 @@ -111,7 +111,7 @@ bool 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); @@ -137,10 +137,10 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) # 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 */ @@ -153,7 +153,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) 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) @@ -178,13 +178,13 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid) *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 */ diff --git a/src/hooks.c b/src/hooks.c index d4e14c88f..fe267a254 100644 --- a/src/hooks.c +++ b/src/hooks.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2015 Todd C. Miller + * Copyright (c) 2012-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -147,40 +147,40 @@ register_hook_internal(struct sudo_hook_list *head, 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. */ @@ -211,12 +211,12 @@ deregister_hook_internal(struct sudo_hook_list *head, 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: @@ -237,10 +237,10 @@ deregister_hook(struct sudo_hook *hook) break; default: /* XXX - use define for unknown value */ - rval = 1; + ret = 1; break; } } - debug_return_int(rval); + debug_return_int(ret); } diff --git a/src/load_plugins.c b/src/load_plugins.c index 403ae03c1..861ab5b16 100644 --- a/src/load_plugins.c +++ b/src/load_plugins.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 Todd C. Miller + * Copyright (c) 2009-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -108,7 +108,7 @@ static bool 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) { @@ -131,10 +131,10 @@ sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize) 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 @@ -279,14 +279,14 @@ sudo_load_plugins(struct plugin_container *policy_plugin, 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); } @@ -306,9 +306,9 @@ sudo_load_plugins(struct plugin_container *policy_plugin, 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 */ @@ -321,16 +321,16 @@ sudo_load_plugins(struct plugin_container *policy_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; } @@ -349,5 +349,5 @@ sudo_load_plugins(struct plugin_container *policy_plugin, sudo_debug_set_active_instance(sudo_debug_instance); done: - debug_return_bool(rval); + debug_return_bool(ret); } diff --git a/src/regress/ttyname/check_ttyname.c b/src/regress/ttyname/check_ttyname.c index a612d6bce..19950412c 100644 --- a/src/regress/ttyname/check_ttyname.c +++ b/src/regress/ttyname/check_ttyname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2014 Todd C. Miller + * Copyright (c) 2013-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -44,7 +44,7 @@ main(int argc, char *argv[]) { char *tty_libc = NULL, *tty_sudo = NULL; char pathbuf[PATH_MAX]; - int rval = 1; + int ret = 1; initprogname(argc > 0 ? argv[0] : "check_ttyname"); @@ -66,20 +66,20 @@ main(int argc, char *argv[]) /* 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; } diff --git a/src/selinux.c b/src/selinux.c index 096ff747e..c63869a46 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -323,7 +323,7 @@ int 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. */ @@ -367,10 +367,10 @@ selinux_setup(const char *role, const char *type, const char *ttyn, se_state.ttyn, 1); #endif - rval = 0; + ret = 0; done: - debug_return_int(rval); + debug_return_int(ret); } void diff --git a/src/signal.c b/src/signal.c index 3fe38eaa6..69cdaa9b9 100644 --- a/src/signal.c +++ b/src/signal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 Todd C. Miller + * Copyright (c) 2009-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -173,7 +173,7 @@ int 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++) { @@ -187,7 +187,7 @@ sudo_sigaction(int signo, struct sigaction *sa, struct sigaction *osa) break; } } - rval = sigaction(signo, sa, osa); + ret = sigaction(signo, sa, osa); - debug_return_int(rval); + debug_return_int(ret); } diff --git a/src/sudo.c b/src/sudo.c index a467ea5fd..49b48abdc 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -385,7 +385,7 @@ fix_fds(void) 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) /* @@ -401,7 +401,7 @@ fill_group_list(struct user_details *ud, int system_maxgroups) } /* 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 @@ -410,7 +410,7 @@ fill_group_list(struct user_details *ud, int system_maxgroups) */ 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)); @@ -418,11 +418,11 @@ fill_group_list(struct user_details *ud, int system_maxgroups) 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 * @@ -943,7 +943,7 @@ restore_nproc(void) 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)) { @@ -966,11 +966,11 @@ set_user_groups(struct command_details *details) (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); } /* @@ -981,7 +981,7 @@ done: 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 @@ -1120,10 +1120,10 @@ exec_setup(struct command_details *details, const char *ptyname, int ptyfd) } } - rval = true; + ret = true; done: - debug_return_bool(rval); + debug_return_bool(ret); } /* @@ -1246,7 +1246,7 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings, 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[] */ @@ -1263,12 +1263,12 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *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); } @@ -1277,7 +1277,7 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings, 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 @@ -1298,15 +1298,15 @@ policy_close(struct plugin_container *plugin, int exit_status, int error_code) 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 @@ -1314,7 +1314,7 @@ policy_check(struct plugin_container *plugin, int argc, char * const argv[], 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) { @@ -1322,17 +1322,17 @@ policy_check(struct plugin_container *plugin, int argc, char * const argv[], 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) { @@ -1341,15 +1341,15 @@ policy_list(struct plugin_container *plugin, int argc, char * const argv[], 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) { @@ -1358,9 +1358,9 @@ policy_validate(struct plugin_container *plugin) 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 @@ -1380,7 +1380,7 @@ policy_invalidate(struct plugin_container *plugin, int remove) int policy_init_session(struct command_details *details) { - int rval = true; + int ret = true; debug_decl(policy_init_session, SUDO_DEBUG_PCOMM) /* @@ -1402,16 +1402,16 @@ policy_init_session(struct command_details *details) 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 @@ -1420,7 +1420,7 @@ iolog_open(struct plugin_container *plugin, struct sudo_settings *settings, 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[] */ @@ -1436,22 +1436,22 @@ iolog_open(struct plugin_container *plugin, struct sudo_settings *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 @@ -1470,16 +1470,16 @@ iolog_close(struct plugin_container *plugin, int exit_status, int error_code) 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); } /* diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 3b89193c2..9c6a1ac1e 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -845,7 +845,7 @@ selinux_edit_copy_tfiles(struct command_details *command_details, 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; @@ -905,7 +905,7 @@ selinux_edit_copy_tfiles(struct command_details *command_details, 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")); @@ -927,7 +927,7 @@ selinux_edit_copy_tfiles(struct command_details *command_details, 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 */ @@ -940,7 +940,7 @@ sudo_edit(struct command_details *command_details) { 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; @@ -1025,7 +1025,7 @@ sudo_edit(struct command_details *command_details) 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; @@ -1052,7 +1052,7 @@ sudo_edit(struct command_details *command_details) 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. */ diff --git a/src/tgetpass.c b/src/tgetpass.c index 9b94c0e2b..21f98bb83 100644 --- a/src/tgetpass.c +++ b/src/tgetpass.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1998-2005, 2007-2015 + * Copyright (c) 1996, 1998-2005, 2007-2016 * Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any @@ -54,7 +54,7 @@ static char *sudo_askpass(const char *, const char *); 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) { @@ -67,14 +67,14 @@ suspend(int signo, struct sudo_conv_callback *callback) 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); } /* diff --git a/src/ttyname.c b/src/ttyname.c index 1f99efed7..9b94ba8f1 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -174,7 +174,7 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin, char *name, size_t { 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; @@ -281,7 +281,7 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin, char *name, size_t 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", @@ -293,8 +293,8 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin, char *name, size_t } /* 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) @@ -302,7 +302,7 @@ done: for (i = 0; i < num_subdirs; i++) free(subdirs[i]); free(subdirs); - debug_return_str(rval); + debug_return_str(ret); } /* @@ -314,7 +314,7 @@ static char * 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) @@ -335,7 +335,7 @@ sudo_ttyname_dev(dev_t rdev, char *name, size_t namelen) "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; @@ -345,15 +345,15 @@ sudo_ttyname_dev(dev_t rdev, char *name, size_t namelen) "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; @@ -365,10 +365,10 @@ sudo_ttyname_dev(dev_t rdev, char *name, size_t namelen) /* * 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 @@ -383,7 +383,7 @@ get_process_ttyname(char *name, size_t namelen) 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) /* @@ -411,8 +411,8 @@ get_process_ttyname(char *name, size_t namelen) 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); @@ -424,7 +424,7 @@ get_process_ttyname(char *name, size_t namelen) } free(ki_proc); - debug_return_str(rval); + debug_return_str(ret); } #elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) /* @@ -434,7 +434,7 @@ get_process_ttyname(char *name, size_t namelen) 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; @@ -453,7 +453,7 @@ get_process_ttyname(char *name, size_t namelen) #endif if (rdev != (dev_t)-1) { errno = serrno; - rval = sudo_ttyname_dev(rdev, name, namelen); + ret = sudo_ttyname_dev(rdev, name, namelen); goto done; } } @@ -461,11 +461,11 @@ get_process_ttyname(char *name, size_t namelen) 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__) /* @@ -476,7 +476,7 @@ char * 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; @@ -505,7 +505,7 @@ get_process_ttyname(char *name, size_t namelen) } if (tdev > 0) { errno = serrno; - rval = sudo_ttyname_dev(tdev, name, namelen); + ret = sudo_ttyname_dev(tdev, name, namelen); goto done; } break; @@ -519,11 +519,11 @@ get_process_ttyname(char *name, size_t namelen) 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) /* @@ -534,7 +534,7 @@ char * 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) @@ -546,7 +546,7 @@ get_process_ttyname(char *name, size_t namelen) 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; } @@ -554,11 +554,11 @@ get_process_ttyname(char *name, size_t namelen) 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 /* diff --git a/src/utmp.c b/src/utmp.c index ea87ba71b..a372a9411 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Todd C. Miller + * Copyright (c) 2011-2016 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -176,7 +176,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd, 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. */ @@ -194,16 +194,16 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd, } 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) @@ -224,9 +224,9 @@ utmp_logout(const char *line, int status) # 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 */ @@ -282,7 +282,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd, 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) @@ -323,24 +323,24 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd, 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) @@ -360,13 +360,13 @@ utmp_logout(const char *line, int status) 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 */