X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Flabel.c;h=09ded642fb1d51003230b09e41e484ae0dd48209;hp=d037c4c93215bfe67b84439b5eb27c3100c41123;hb=46824d0e6b2aae8f503464368d02c1da992f56f1;hpb=5c0532d1cc989d2f78d2cd4a18058daa58143705 diff --git a/src/label.c b/src/label.c index d037c4c93..09ded642f 100644 --- a/src/label.c +++ b/src/label.c @@ -65,7 +65,7 @@ int label_init(void) { return r; } -int label_fix(const char *path) { +int label_fix(const char *path, bool ignore_enoent) { int r = 0; #ifdef HAVE_SELINUX @@ -90,6 +90,10 @@ int label_fix(const char *path) { /* If the FS doesn't support labels, then exit without warning */ if (r < 0 && errno == ENOTSUP) return 0; + + /* Ignore ENOENT in some cases */ + if (r < 0 && ignore_enoent && errno == ENOENT) + return 0; } } @@ -258,20 +262,15 @@ int label_mkdir( if (use_selinux() && label_hnd) { - if (path[0] == '/') + if (path_is_absolute(path)) r = selabel_lookup_raw(label_hnd, &fcon, path, mode); else { - char *cwd = NULL, *newpath = NULL; - - cwd = get_current_dir_name(); + char *newpath = NULL; - if (cwd || asprintf(&newpath, "%s/%s", cwd, path) < 0) { - free(cwd); - return -errno; - } + if (!(newpath = path_make_absolute_cwd(path))) + return -ENOMEM; r = selabel_lookup_raw(label_hnd, &fcon, newpath, mode); - free(cwd); free(newpath); }