diff options
author | Roy Marples <roy@marples.name> | 2007-10-04 16:26:44 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2007-10-04 16:26:44 +0000 |
commit | e2e40afddef5253d5d669002b9afbea6bf3d6c66 (patch) | |
tree | 41314af54291fc3358361132463307a4b0da9d20 /src | |
parent | d65c484f3a1b210048045613c524c29fdfcb470c (diff) |
punt rc_is_exec
Diffstat (limited to 'src')
-rw-r--r-- | src/librc-misc.c | 19 | ||||
-rw-r--r-- | src/librc.c | 11 | ||||
-rw-r--r-- | src/librc.h | 1 | ||||
-rw-r--r-- | src/rc.h | 5 | ||||
-rw-r--r-- | src/rc.map | 1 |
5 files changed, 8 insertions, 29 deletions
diff --git a/src/librc-misc.c b/src/librc-misc.c index 060bee09..29d2763d 100644 --- a/src/librc-misc.c +++ b/src/librc-misc.c @@ -15,10 +15,6 @@ #define PATH_PREFIX RC_LIBDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin" -#ifndef S_IXUGO -# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) -#endif - void *rc_xmalloc (size_t size) { void *value = malloc (size); @@ -166,21 +162,6 @@ bool rc_is_dir (const char *pathname) } librc_hidden_def(rc_is_dir) -bool rc_is_exec (const char *pathname) -{ - struct stat buf; - - if (! pathname) - return (false); - - if (lstat (pathname, &buf) == 0) - return (buf.st_mode & S_IXUGO); - - errno = 0; - return (false); -} -librc_hidden_def(rc_is_exec) - char **rc_ls_dir (const char *dir, int options) { DIR *dp; diff --git a/src/librc.c b/src/librc.c index dcbc9872..58f450da 100644 --- a/src/librc.c +++ b/src/librc.c @@ -15,6 +15,10 @@ #define SOFTLEVEL RC_SVCDIR "/softlevel" +#ifndef S_IXUGO +# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH) +#endif + /* File stream used for plugins to write environ vars to */ FILE *rc_environ_fd = NULL; @@ -173,6 +177,7 @@ bool rc_service_exists (const char *service) char *file; bool retval = false; int len; + struct stat buf; if (! service) return (false); @@ -185,9 +190,9 @@ bool rc_service_exists (const char *service) service[len - 1] == 'h') return (false); - file = rc_service_resolve (service); - if (rc_exists (file)) - retval = rc_is_exec (file); + file = rc_service_resolve (service); + if (stat (file, &buf) == 0 && buf.st_mode & S_IXUGO) + retval = true; free (file); return (retval); } diff --git a/src/librc.h b/src/librc.h index 1506f39a..a370754f 100644 --- a/src/librc.h +++ b/src/librc.h @@ -66,7 +66,6 @@ librc_hidden_proto(rc_env_filter) librc_hidden_proto(rc_exists) librc_hidden_proto(rc_find_pids) librc_hidden_proto(rc_is_dir) -librc_hidden_proto(rc_is_exec) librc_hidden_proto(rc_ls_dir) librc_hidden_proto(rc_rm_dir) librc_hidden_proto(rc_runlevel_exists) @@ -468,11 +468,6 @@ bool rc_exists (const char *pathname); * @return true if it's a directory, otherwise false */ bool rc_is_dir (const char *pathname); -/*! Check if the file is marked executable or not - * @param pathname to check - * @return true if it's marked executable, otherwise false */ -bool rc_is_exec (const char *pathname); - /*! @name rc_ls_dir options */ /*! Ensure that an init.d service exists for each file returned */ #define RC_LS_INITD 0x01 @@ -16,7 +16,6 @@ global: rc_exists; rc_find_pids; rc_is_dir; - rc_is_exec; rc_ls_dir; rc_rm_dir; rc_runlevel_exists; |