len = asprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",
user, '\0', user, '\0', user, '\0', tty ? tty : "", '\0');
if (len == -1) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
(void)usrinfo(SETUINFO, info, len);
if (ngids != 0) {
gids = reallocarray(NULL, ngids, sizeof(GETGROUPS_T));
if (gids == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
ngids = 0;
if (namelen == cur->pnamelen &&
strncasecmp(name, cur->pname, cur->pnamelen) == 0) {
if ((cur->pval = strdup(path)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
break;
}
debug_return_int(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (debug_file != NULL) {
free(debug_file->debug_file);
free(debug_file->debug_flags);
debug_return_int(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (options != NULL) {
while (nopts--)
free(options[nopts]);
prev_locale = strdup(setlocale(LC_ALL, NULL));
if (prev_locale == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
goto done;
}
if ((pr->resp = strdup(pass)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
ret = PAM_BUF_ERR;
goto done;
}
if (np_size < op_len + challenge_len + 7) {
char *p = realloc(new_prompt, op_len + challenge_len + 7);
if (p == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(AUTH_FATAL);
}
np_size = op_len + challenge_len + 7;
debug_return_bool(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
def->sd_un.str = NULL;
} else {
if ((def->sd_un.str = strdup(val)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
}
if (op == add) {
cur = calloc(1, sizeof(struct list_member));
if (cur == NULL || (cur->value = strndup(val, len)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(cur);
debug_return_bool(false);
}
debug_return_str(NULL);
editor = strndup(cp, (size_t)(ep - cp));
if (editor == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_str(NULL);
}
nargc += nfiles + 1;
nargv = reallocarray(NULL, nargc + 1, sizeof(char *));
if (nargv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(editor);
debug_return_str(NULL);
}
for (nargc = 1; (cp = sudo_strsplit(NULL, edend, " \t", &ep)) != NULL; nargc++) {
nargv[nargc] = strndup(cp, (size_t)(ep - cp));
if (nargv[nargc] == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
while (nargc--)
free(nargv[nargc]);
debug_return_str(NULL);
if (env.envp == NULL) {
env.env_size = 0;
env.env_len = 0;
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
#ifdef ENV_DEBUG
init_lexer();
if (!init_aliases()) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = false;
}
free(sudoers);
if (path != NULL) {
if ((sudoers = strdup(path)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = false;
}
} else {
init_lexer();
if (!init_aliases()) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = false;
}
free(sudoers);
if (path != NULL) {
if ((sudoers = strdup(path)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = false;
}
} else {
if (ac != 0) {
argv = reallocarray(NULL, ac, sizeof(char *));
if (argv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
ac = 0;
bindtextdomain("sudoers", LOCALEDIR);
if (sudo_setpwent() == -1 || sudo_setgrent() == -1) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
/* Get next session ID and convert it into a path. */
tofree = malloc(sizeof(_PATH_SUDO_IO_LOGDIR) + sizeof(sessid) + 2);
if (tofree == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
memcpy(tofree, _PATH_SUDO_IO_LOGDIR, sizeof(_PATH_SUDO_IO_LOGDIR));
prelen = strlen(prefix);
dst = path = malloc(prelen + PATH_MAX);
if (path == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
}
*path = '\0';
free(ldap_conf.host);
if ((ldap_conf.host = strdup(hostbuf)) == NULL)
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(ldap_conf.host != NULL);
overflow:
buf = strdup(entry->val);
if (buf == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
for ((uri = strtok_r(buf, " \t", &last)); uri != NULL; (uri = strtok_r(NULL, " \t", &last))) {
/* Store parsed URI(s) in host for ldap_create() or ldap_init(). */
free(ldap_conf.host);
if ((ldap_conf.host = strdup(hostbuf)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
len += strlen(uri->val) + 1;
}
if (len == 0 || (buf = malloc(len)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
} else {
char *cp = buf;
digest->digest_type = digest_type;
digest->digest_str = strndup(cp, (size_t)(ep - cp));
if (digest->digest_str == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_ptr(NULL);
}
cp = ep + 1;
/* walk through options */
for (p = bv; *p != NULL; p++) {
if ((var = strdup((*p)->bv_val)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
DPRINTF2("ldap sudoOption: '%s'", var);
debug_return_bool(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (result)
ldap_msgfree(result);
debug_return_bool(false);
}
debug_return_bool(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
ldap_msgfree(result);
debug_return_bool(false);
overflow:
if (ldap_conf.timed)
sz += TIMEFILTER_LENGTH;
if ((buf = malloc(sz)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_str(NULL);
}
*buf = '\0';
(ldap_conf.timed || ldap_conf.search_filter) ? ")" : "");
}
if (len == -1)
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_str(filt);
}
reslen = ((strlen(secret) + 3) / 4 * 3);
result = malloc(reslen + 1);
if (result == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
} else {
len = base64_decode(secret, result, reslen);
if (len == (size_t)-1) {
ldap_conf.bindpw = sudo_ldap_decode_secret(buf);
if (ldap_conf.bindpw == NULL) {
if ((ldap_conf.bindpw = strdup(buf)) == NULL)
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
free(ldap_conf.binddn);
ldap_conf.binddn = ldap_conf.rootbinddn;
free(*(char **)(cur->valp));
if (*value && (cp = strdup(value)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
*(char **)(cur->valp) = cp;
if (len > 0) {
head = (struct ldap_config_str_list *)cur->valp;
if ((str = malloc(sizeof(*str) + len)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
memcpy(str->val, value, len + 1);
STAILQ_INIT(&ldap_conf.netgroup_base);
if (ldap_conf.search_filter == NULL || ldap_conf.netgroup_search_filter == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
if (!ldap_conf.host) {
ldap_conf.host = strdup("localhost");
if (ldap_conf.host == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
}
cp = ldap_conf.search_filter;
ldap_conf.search_filter = malloc(len + 3);
if (ldap_conf.search_filter == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
ldap_conf.search_filter[0] = '(';
filt = sudo_ldap_build_default_filter();
if (filt == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
STAILQ_FOREACH(base, &ldap_conf.base, entries) {
/* Create a handle container. */
handle = calloc(1, sizeof(struct sudo_ldap_handle));
if (handle == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rc = -1;
goto done;
}
filt = sudo_ldap_build_default_filter();
if (filt == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
DPRINTF1("Looking for cn=defaults: %s", filt);
*/
lres = sudo_ldap_result_alloc();
if (lres == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_ptr(NULL);
}
for (pass = 0; pass < 2; pass++) {
/* Add the seach result to list of search results. */
DPRINTF1("adding search result");
if (sudo_ldap_result_add_search(lres, ld, result) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(filt);
sudo_ldap_result_free(lres);
debug_return_ptr(NULL);
sudo_ldap_check_host(ld, entry)) {
lres->host_matches = true;
if (sudo_ldap_result_add_entry(lres, entry) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(filt);
sudo_ldap_result_free(lres);
debug_return_ptr(NULL);
*/
result = sudo_ldap_result_alloc();
if (result == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_ptr(NULL);
}
*/
LDAP_FOREACH(entry, last->ldap, last->searchresult) {
if (sudo_ldap_result_add_entry(result, entry) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudo_ldap_result_free(result);
result = NULL;
break;
size += strlen(*av) + 1;
command = cp = malloc(size);
if (command == NULL) {
- sudo_warn(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
for (av = argv; *av != NULL; av++) {
if (!ferror(fp))
rval = true;
} else {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
(void) fclose(fp);
}
debug_return_str(line);
oom:
free(evstr);
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_str(NULL);
toobig:
free(evstr);
user_stat->st_ino == sudoers_stat.st_ino)) {
free(safe_cmnd);
if ((safe_cmnd = strdup(cp)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
cp = NULL; /* fail closed */
}
break;
free(safe_cmnd);
if ((safe_cmnd = strdup(sudoers_cmnd)) != NULL)
debug_return_bool(true);
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
}
debug_return_bool(false);
}
free(safe_cmnd);
if ((safe_cmnd = strdup(sudoers_cmnd)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
debug_return_bool(true);
user_stat->st_ino == sudoers_stat.st_ino)) {
free(safe_cmnd);
if ((safe_cmnd = strdup(buf)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
dent = NULL;
}
break;
if (cs->role != NULL) {
user_role = strdup(cs->role);
if (user_role == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
SET(validated, VALIDATE_ERROR);
goto done;
}
if (cs->type != NULL) {
user_type = strdup(cs->type);
if (user_type == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
SET(validated, VALIDATE_ERROR);
goto done;
}
if (cs->privs != NULL) {
runas_privs = strdup(cs->privs);
if (runas_privs == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
SET(validated, VALIDATE_ERROR);
goto done;
}
if (cs->limitprivs != NULL) {
runas_limitprivs = strdup(cs->limitprivs);
if (runas_limitprivs == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
SET(validated, VALIDATE_ERROR);
goto done;
}
debug_return_int(flags);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
bad:
debug_return_int(MODE_ERROR);
}
debug_return_int(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
bad:
while (info_len--)
free(command_info[info_len]);
}
if ((new_prompt = malloc(++len)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_str(NULL);
}
debug_return_bool(true);
oom:
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudo_sss_attrfree(dst);
debug_return_bool(false);
}
dst->num_attrs = 0;
dst->attrs = reallocarray(NULL, src->num_attrs, sizeof(struct sss_sudo_attr));
if (dst->attrs == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
for (i = 0; i < src->num_attrs; ++i) {
if (!sudo_sss_attrcpy(dst->attrs + i, src->attrs + i)) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
dst->num_attrs = i;
sudo_sss_rulefree(dst);
debug_return_bool(false);
sudo_debug_printf(SUDO_DEBUG_DEBUG, "malloc: cnt=%d", in_res->num_rules);
if ((out_res = calloc(1, sizeof(struct sss_sudo_result))) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_ptr(NULL);
}
if (in_res->num_rules > 0) {
out_res->rules =
reallocarray(NULL, in_res->num_rules, sizeof(struct sss_sudo_rule));
if (out_res->rules == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(out_res);
debug_return_ptr(NULL);
}
struct sss_sudo_rule *rules =
reallocarray(out_res->rules, l, sizeof(struct sss_sudo_rule));
if (out_res->rules == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
while (l--) {
sudo_sss_rulefree(out_res->rules + l);
}
/* Create a handle container. */
handle = malloc(sizeof(struct sudo_sss_handle));
if (handle == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(ENOMEM);
}
digest->digest_type = digest_type;
digest->digest_str = strndup(cp, (size_t)(ep - cp));
if (digest->digest_str == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_ptr(NULL);
}
cp = ep + 1;
sudo_debug_printf(SUDO_DEBUG_INFO, "sssd/ldap sudoOption: '%s'",
val_array[i]);
if ((v = strdup(val_array[i])) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
bindtextdomain("sudoers", LOCALEDIR);
if (sudo_setpwent() == -1 || sudo_setgrent() == -1) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
NewArgc = 1;
NewArgv = reallocarray(NULL, NewArgc + 1, sizeof(char *));
if (NewArgv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = -1;
goto done;
}
NewArgc = argc;
NewArgv = reallocarray(NULL, NewArgc + 2, sizeof(char *));
if (NewArgv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = -1;
goto done;
}
if (ISSET(sudo_mode, MODE_LOGIN_SHELL) && runas_pw != NULL) {
NewArgv[0] = strdup(runas_pw->pw_shell);
if (NewArgv[0] == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
free(NewArgv);
rval = -1;
goto done;
if (safe_cmnd == NULL) {
if ((safe_cmnd = strdup(user_cmnd)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rval = -1;
goto done;
}
debug_decl(init_vars, SUDOERS_DEBUG_PLUGIN)
if (!sudoers_initlocale(setlocale(LC_ALL, NULL), def_sudoers_locale)) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
/* Allocate user_stat for find_path() and match functions. */
user_stat = calloc(1, sizeof(struct stat));
if (user_stat == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(NOT_FOUND_ERROR);
}
for (size = 0, av = NewArgv + 1; *av; av++)
size += strlen(*av) + 1;
if (size == 0 || (user_args = malloc(size)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
if (ISSET(sudo_mode, MODE_SHELL|MODE_LOGIN_SHELL)) {
free(debug_file->debug_flags);
free(debug_file);
}
- sudo_warnx_nodebug(U_("unable to allocate memory"));
+ sudo_warnx_nodebug(U_("%s: %s"), "sudoers_debug_parse_flags",
+ U_("unable to allocate memory"));
return false;
}
reallocarray(iov, iovmax <<= 1, sizeof(*iov)) :
reallocarray(NULL, iovmax = 32, sizeof(*iov));
if (iov == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
linelen = (size_t)(nl - line) + 1;
iov[iovcnt].iov_base = line;
/* Allocate new search node */
if ((sn = calloc(1, sizeof(*sn))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sn->type = type;
sn->or = or;
sn->negated = not;
* 3) command with args
*/
if ((li = calloc(1, sizeof(*li))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (getline(&buf, &bufsize, fp) == -1 ||
getline(&li->cwd, &cwdsize, fp) == -1 ||
getline(&li->cmd, &cmdsize, fp) == -1) {
goto bad;
}
if ((li->user = strndup(cp, (size_t)(ep - cp))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* runas user */
cp = ep + 1;
goto bad;
}
if ((li->runas_user = strndup(cp, (size_t)(ep - cp))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* runas group */
cp = ep + 1;
}
if (cp != ep) {
if ((li->runas_group = strndup(cp, (size_t)(ep - cp))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
/* tty, followed by optional rows + columns */
if ((ep = strchr(cp, ':')) == NULL) {
/* just the tty */
if ((li->tty = strdup(cp)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
} else {
/* tty followed by rows + columns */
if ((li->tty = strndup(cp, (size_t)(ep - cp))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
cp = ep + 1;
/* need to NULL out separator to use strtonum() */
if ((ep = strchr(cp, ':')) != NULL) {
sessions_size = 36 * 36 / 2;
sessions = reallocarray(sessions, sessions_size, 2 * sizeof(char *));
if (sessions == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sessions_size *= 2;
}
if ((sessions[sessions_len] = strdup(dp->d_name)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sessions_len++;
}
closedir(d);
initprogname(argc > 0 ? argv[0] : "testsudoers");
if (!sudoers_initlocale(setlocale(LC_ALL, ""), def_sudoers_locale))
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have own domain */
textdomain("sudoers");
if (pwfile)
setpwfile(pwfile);
if (sudo_setpwent() == -1 || sudo_setgrent() == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (argc < 2) {
if (!dflag)
if ((p = strchr(user_host, '.'))) {
*p = '\0';
if ((user_shost = strdup(user_host)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
*p = '.';
} else {
user_shost = user_host;
size += strlen(*from) + 1;
if ((user_args = malloc(size)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
for (to = user_args, from = argv; *from; from++) {
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args))
initprogname(argc > 0 ? argv[0] : "visudo");
if (!sudoers_initlocale(setlocale(LC_ALL, ""), def_sudoers_locale))
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have visudo domain */
textdomain("sudoers");
usage(1);
if (sudo_setpwent() == -1 || sudo_setgrent() == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Mock up a fake sudo_user struct. */
user_cmnd = user_base = "";
}
whitelist = reallocarray(NULL, whitelist_len + 1, sizeof(char *));
if (whitelist == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
whitelist_len = 0;
for (cp = sudo_strsplit(def_editor, def_editor_end, ":", &ep);
cp != NULL; cp = sudo_strsplit(NULL, def_editor_end, ":", &ep)) {
whitelist[whitelist_len] = strndup(cp, (size_t)(ep - cp));
if (whitelist[whitelist_len] == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
whitelist_len++;
}
whitelist[whitelist_len] = NULL;
/* Create the temp file if needed and set timestamp. */
if (sp->tpath == NULL) {
if (asprintf(&sp->tpath, "%s.tmp", sp->path) == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (tfd < 0)
sudo_fatal("%s", sp->tpath);
if (entry == NULL) {
entry = calloc(1, sizeof(*entry));
if (entry == NULL || (entry->path = strdup(path)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* entry->modified = 0; */
entry->fd = open(entry->path, open_flags, sudoers_mode);
/* entry->tpath = NULL; */
if ((p = strchr(user_host, '.'))) {
*p = '\0';
if ((user_shost = strdup(user_host)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
*p = '.';
} else {
user_shost = user_host;
alias_freelist = rbcreate(alias_compare);
if (alias_freelist == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
pass = tgetpass(msg->msg, msg->timeout, flags);
if (pass == NULL)
goto err;
- if ((repl->reply = strdup(pass)) == NULL)
- sudo_fatalx_nodebug(U_("unable to allocate memory"));
+ if ((repl->reply = strdup(pass)) == NULL) {
+ sudo_fatalx_nodebug(U_("%s: %s"), "sudo_conversation",
+ U_("unable to allocate memory"));
+ }
memset_s(pass, SUDO_CONV_REPL_MAX, 0, strlen(pass));
break;
case SUDO_CONV_INFO_MSG:
sudo_debug_printf(SUDO_DEBUG_DIAG, "scheduled SIG%s for child", signame);
if ((sigfwd = calloc(1, sizeof(*sigfwd))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sigfwd->signo = signo;
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
#endif
nenvp = reallocarray(NULL, env_size, sizeof(*envp));
if (nenvp == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
memcpy(nenvp, envp, env_len * sizeof(*envp));
nenvp[env_len] = NULL;
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
# endif
if (preload == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
nenvp[env_len++] = preload;
nenvp[env_len] = NULL;
} else {
int len = asprintf(&preload, "%s=%s%s%s", RTLD_PRELOAD_VAR,
sudo_conf_noexec_path(), RTLD_PRELOAD_DELIM, nenvp[preload_idx]);
if (len == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
nenvp[preload_idx] = preload;
}
# ifdef RTLD_PRELOAD_ENABLE_VAR
/* Allocate and add to head of list. */
if ((iob = malloc(sizeof(*iob))) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
iob->revent = sudo_ev_alloc(rfd, SUDO_EV_READ, io_callback, iob);
iob->wevent = sudo_ev_alloc(wfd, SUDO_EV_WRITE, io_callback, iob);
iob->len = 0;
iob->action = action;
iob->buf[0] = '\0';
if (iob->revent == NULL || iob->wevent == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
SLIST_INSERT_HEAD(head, iob, entries);
debug_return;
policy_plugin->handle = handle;
policy_plugin->path = strdup(path);
if (policy_plugin->path == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
}
policy_plugin->name = info->symbol_name;
if (handle != NULL) {
container = calloc(1, sizeof(*container));
if (container == NULL || (container->path = strdup(path)) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
}
container->handle = handle;
/* Default policy plugin */
info = calloc(1, sizeof(*info));
if (info == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
info->symbol_name = "sudoers_policy";
if (TAILQ_EMPTY(io_plugins)) {
info = calloc(1, sizeof(*info));
if (info == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
info->symbol_name = "sudoers_io";
env_add = reallocarray(NULL, env_size, sizeof(char *));
if (env_add == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Pass progname to plugin so it can call initprogname() */
progname = getprogname();
i = sudo_conf_max_groups();
if (i != -1) {
if (asprintf(&cp, "%d", i) == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
sudo_settings[ARG_MAX_GROUPS].value = cp;
}
tmp = reallocarray(env_add, env_size, 2 * sizeof(char *));
if (tmp == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
env_add = tmp;
env_size *= 2;
}
cmnd = dst = reallocarray(NULL, cmnd_size, 2);
if (cmnd == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
for (av = argv; *av != NULL; av++) {
for (src = *av; *src != '\0'; src++) {
/* quote potential meta characters */
av = reallocarray(NULL, ac + 1, sizeof(char *));
if (av == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
av[0] = (char *)user_details.shell; /* plugin may override shell */
if (cmnd != NULL) {
av[1] = "-c";
pfd_new = malloc(sizeof(*pfd));
if (pfd_new == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
pfd_new->lowfd = fd;
pfd_new->highfd = fd;
pfd_new->flags = fcntl(fd, F_GETFD);
/* Create bitmap of preserved (relocated) fds. */
fdsp = calloc(howmany(lastfd + 1, NFDBITS), sizeof(fd_mask));
if (fdsp == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
TAILQ_FOREACH(pfd, pfds, entries) {
FD_SET(pfd->lowfd, fdsp);
}
rc = asprintf(&message, "newrole: old-context=%s new-context=%s",
old_context, new_context);
if (rc == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
message, NULL, NULL, ttyn, result);
if (rc <= 0)
* Convert "context" back into a string and verify it.
*/
if ((new_context = strdup(context_str(context))) == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto bad;
}
if (security_check_context(new_context) < 0) {
continue;
nargv = reallocarray(NULL, argc + 2, sizeof(char *));
if (nargv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return;
}
if (noexec)
argv++;
argc--;
if ((cmnd = strdup(argv[0])) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* If invoked as a login shell, modify argv[0] accordingly. */
if (login_shell) {
/* Fill in user_info with user name, uid, cwd, etc. */
if ((user_info = get_user_info(&user_details)) == NULL)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Disable core dumps if not enabled in sudo.conf. */
disable_coredumps();
if (ud->ngroups > 0) {
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
if (ud->groups == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
/* No error on insufficient space if user specified max_groups. */
free(ud->groups);
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
if (ud->groups == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto done;
}
rval = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
}
debug_return_str(gid_list);
oom:
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
/*
len = asprintf(tfile, "%s/%s.XXXXXXXX", edit_tmpdir, cp);
}
if (len == -1)
- sudo_fatalx(U_("unable to allocate memory"));
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
tfd = mkstemps(*tfile, suff ? strlen(suff) : 0);
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"%s -> %s, fd %d", ofile, *tfile, tfd);
sesh_nargs = 3 + (nfiles * 2) + 1;
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
if (sesh_args == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
*sesh_ap++ = "sesh";
sesh_nargs = 3 + (nfiles * 2) + 1;
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
if (sesh_args == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_int(-1);
}
*sesh_ap++ = "sesh";
/* Copy editor files to temporaries. */
tf = calloc(nfiles, sizeof(*tf));
if (tf == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto cleanup;
}
#ifdef HAVE_SELINUX
nargc = editor_argc + nfiles;
nargv = reallocarray(NULL, nargc + 1, sizeof(char *));
if (nargv == NULL) {
- sudo_warnx(U_("unable to allocate memory"));
+ sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
goto cleanup;
}
for (ac = 0; ac < editor_argc; ac++)