X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Futil.c;h=0b0063ee0e6078a48cdec42f053be97c42a7742a;hb=be11c12e49d39a0f1f0f83a67a212c3ff0e98b3d;hp=c2ef34dd4378af94500e6cfe3a830186a920c013;hpb=afea26ad7d406d8b6c95d2642cb5a1d807b87546;p=elogind.git diff --git a/src/util.c b/src/util.c index c2ef34dd4..0b0063ee0 100644 --- a/src/util.c +++ b/src/util.c @@ -1,4 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8 -*-*/ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*** This file is part of systemd. @@ -2531,11 +2531,12 @@ char* getlogname_malloc(void) { int getttyname_malloc(char **r) { char path[PATH_MAX], *p, *c; + int k; assert(r); - if (ttyname_r(STDIN_FILENO, path, sizeof(path)) < 0) - return -errno; + if ((k = ttyname_r(STDIN_FILENO, path, sizeof(path))) != 0) + return -k; char_array_0(path); @@ -2980,24 +2981,18 @@ char *ellipsize(const char *s, unsigned length, unsigned percent) { return r; } -void nss_disable_nscd(void) { +int touch(const char *path) { + int fd; - void (*func)(void); + assert(path); - /* This is an internal glibc function call. We are not - * supposed to call this, because we are not nscd. However - * sometimes we feel really dangerous and do it - * nonetheless. Muahahah! But at least we protect this with a - * dlsym() just in case glibc takes this away from us. */ + if ((fd = open(path, O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 0666)) < 0) + return -errno; - if ((func = dlsym(RTLD_DEFAULT, "__nss_disable_nscd"))) { - log_debug("Disabling nscd."); - func(); - } else - log_debug("Cannot disable nscd."); + close_nointr_nofail(fd); + return 0; } - static const char *const ioprio_class_table[] = { [IOPRIO_CLASS_NONE] = "none", [IOPRIO_CLASS_RT] = "realtime",