From 6ca44589b07c2a809718c4a630005b999f53d58d Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Tue, 4 Jun 2013 12:53:32 -0400 Subject: src/libudev/strv.{c,h}: bring in line with upstream In doing so, we better alined util.{c,h} by movig the definitions of freep, fclosep, closep, closedirp, umaskp from util.c to util.h as static inline. We also add strv_env_get to env-util.{c,h} which we forgot to do earlier. Signed-off-by: Anthony G. Basile --- src/libudev/util.c | 70 ------------------------------------------------------ 1 file changed, 70 deletions(-) (limited to 'src/libudev/util.c') diff --git a/src/libudev/util.c b/src/libudev/util.c index b93b5c1b68..09c7033274 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -5948,76 +5948,6 @@ int get_home_dir(char **_h) { return 0; } -int get_shell(char **_sh) { - char *sh; - const char *e; - uid_t u; - struct passwd *p; - - assert(_sh); - - /* Take the user specified one */ - e = getenv("SHELL"); - if (e) { - sh = strdup(e); - if (!sh) - return -ENOMEM; - - *_sh = sh; - return 0; - } - - /* Hardcode home directory for root to avoid NSS */ - u = getuid(); - if (u == 0) { - sh = strdup("/bin/sh"); - if (!sh) - return -ENOMEM; - - *_sh = sh; - return 0; - } - - /* Check the database... */ - errno = 0; - p = getpwuid(u); - if (!p) - return errno ? -errno : -ESRCH; - - if (!path_is_absolute(p->pw_shell)) - return -EINVAL; - - sh = strdup(p->pw_shell); - if (!sh) - return -ENOMEM; - - *_sh = sh; - return 0; -} - -void freep(void *p) { - free(*(void**) p); -} - -void fclosep(FILE **f) { - if (*f) - fclose(*f); -} - -void closep(int *fd) { - if (*fd >= 0) - close_nointr_nofail(*fd); -} - -void closedirp(DIR **d) { - if (*d) - closedir(*d); -} - -void umaskp(mode_t *u) { - umask(*u); -} - bool filename_is_safe(const char *p) { if (isempty(p)) -- cgit v1.2.3-54-g00ecf