diff options
author | Roy Marples <roy@marples.name> | 2009-02-28 14:12:03 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2009-02-28 14:12:03 +0000 |
commit | 907ca8a89f47c8982249dd93d1f1d6f9e567f01c (patch) | |
tree | 66187a138b1a15672b9a520ead29a2e83ccb1f53 /src/librc/librc.c | |
parent | f38ef0093915724421052abcf1f4013fe5738d32 (diff) |
Set errno when service does not exist better.
Diffstat (limited to 'src/librc/librc.c')
-rw-r--r-- | src/librc/librc.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c index 204e07f3..b7ab9203 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -392,22 +392,32 @@ rc_service_exists(const char *service) int len; struct stat buf; - if (!service) + if (!service) { + errno = EINVAL; return false; + } len = strlen(service); /* .sh files are not init scripts */ if (len > 2 && service[len - 3] == '.' && service[len - 2] == 's' && - service[len - 1] == 'h') + service[len - 1] == 'h') { + errno = EINVAL; return false; + } - if (!(file = rc_service_resolve(service))) + if (!(file = rc_service_resolve(service))) { + errno = ENOENT; return false; + } - if (stat(file, &buf) == 0 && buf.st_mode & S_IXUGO) - retval = true; + if (stat(file, &buf) == 0) { + if (buf.st_mode & S_IXUGO) + retval = true; + else + errno = ENOEXEC; + } free(file); return retval; } |