chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
parse_boolean: require exact matches
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 88511b69c0a805c0a4ad627028efc4627bf34bf7..49c17eff85fdfa4137cf75551f250cb4068bd537 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-231,9
+231,9
@@
int unlink_noerrno(const char *path) {
int parse_boolean(const char *v) {
assert(v);
int parse_boolean(const char *v) {
assert(v);
- if (streq(v, "1") ||
v[0] == 'y' || v[0] == 'Y' || v[0] == 't' || v[0] == 'T'
|| strcaseeq(v, "on"))
+ if (streq(v, "1") ||
strcaseeq(v, "yes") || strcaseeq(v, "y") || strcaseeq(v, "true") || strcaseeq(v, "t")
|| strcaseeq(v, "on"))
return 1;
return 1;
- else if (streq(v, "0") ||
v[0] == 'n' || v[0] == 'N' || v[0] == 'f' || v[0] == 'F'
|| strcaseeq(v, "off"))
+ else if (streq(v, "0") ||
strcaseeq(v, "no") || strcaseeq(v, "n") || strcaseeq(v, "false") || strcaseeq(v, "f")
|| strcaseeq(v, "off"))
return 0;
return -EINVAL;
return 0;
return -EINVAL;
@@
-3604,6
+3604,17
@@
int null_or_empty_path(const char *fn) {
return null_or_empty(&st);
}
return null_or_empty(&st);
}
+int null_or_empty_fd(int fd) {
+ struct stat st;
+
+ assert(fd >= 0);
+
+ if (fstat(fd, &st) < 0)
+ return -errno;
+
+ return null_or_empty(&st);
+}
+
DIR *xopendirat(int fd, const char *name, int flags) {
int nfd;
DIR *d;
DIR *xopendirat(int fd, const char *name, int flags) {
int nfd;
DIR *d;
@@
-3795,7
+3806,7
@@
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) {
return endswith(de->d_name, suffix);
}
return endswith(de->d_name, suffix);
}
-void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv[]
, char *env[]
) {
+void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv[]) {
pid_t executor_pid;
int r;
pid_t executor_pid;
int r;
@@
-3826,14
+3837,6
@@
void execute_directory(const char *directory, DIR *d, usec_t timeout, char *argv
assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
assert_se(prctl(PR_SET_PDEATHSIG, SIGTERM) == 0);
- if (!strv_isempty(env)) {
- char **i;
-
- STRV_FOREACH(i, env)
- putenv(*i);
- }
-
-
if (!d) {
d = _d = opendir(directory);
if (!d) {
if (!d) {
d = _d = opendir(directory);
if (!d) {
@@
-5427,7
+5430,7
@@
bool string_has_cc(const char *p, const char *ok) {
for (t = p; *t; t++) {
if (ok && strchr(ok, *t))
for (t = p; *t; t++) {
if (ok && strchr(ok, *t))
-
return fals
e;
+
continu
e;
if (*t > 0 && *t < ' ')
return true;
if (*t > 0 && *t < ' ')
return true;