diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-04-06 20:11:41 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-04-07 15:42:25 +0200 |
commit | 527b7a421ff3927d4f3f170b1b143452e88ae1dc (patch) | |
tree | cfb13e123c6dfd547fb005db63a480ca709b46da /src/login | |
parent | 64f75d7a2898e0c0d2b66f93ddd34ffd345bb3c5 (diff) |
util: rework cunescape(), improve error handling
Change cunescape() to return a normal error code, so that we can
distuingish OOM errors from parse errors.
This also adds a flags parameter to control whether "relaxed" or normal
parsing shall be done. If set no parse failures are generated, and the
only reason why cunescape() can fail is OOM.
Diffstat (limited to 'src/login')
-rw-r--r-- | src/login/logind-acl.c | 3 | ||||
-rw-r--r-- | src/login/logind-inhibit.c | 12 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c index 941fd724a5..d2b3337788 100644 --- a/src/login/logind-acl.c +++ b/src/login/logind-acl.c @@ -253,8 +253,7 @@ int devnode_acl_all(struct udev *udev, FOREACH_DIRENT(dent, dir, return -errno) { _cleanup_free_ char *unescaped_devname = NULL; - unescaped_devname = cunescape(dent->d_name); - if (!unescaped_devname) + if (cunescape(dent->d_name, UNESCAPE_RELAX, &unescaped_devname) < 0) return -ENOMEM; n = strappend("/dev/", unescaped_devname); diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index 5d81693e6c..5eb1a2ea65 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -231,18 +231,18 @@ int inhibitor_load(Inhibitor *i) { } if (who) { - cc = cunescape(who); - if (!cc) - return -ENOMEM; + r = cunescape(who, 0, &cc); + if (r < 0) + return r; free(i->who); i->who = cc; } if (why) { - cc = cunescape(why); - if (!cc) - return -ENOMEM; + r = cunescape(why, 0, &cc); + if (r < 0) + return r; free(i->why); i->why = cc; |