chiark / gitweb /
tree-wide: beautify remaining copyright statements
[elogind.git] / src / basic / smack-util.c
index 682a612b10ef068182085aefb29c7f6d0dd68784..2b63eee83637b3018d02e3864ed0075343f0f8ce 100644 (file)
@@ -1,23 +1,8 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
-  Copyright 2013 Intel Corporation
+  Copyright © 2013 Intel Corporation
 
   Author: Auke Kok <auke-jan.h.kok@intel.com>
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <errno.h>
@@ -151,9 +136,22 @@ int mac_smack_fix(const char *path, LabelFixFlags flags) {
         if (!mac_smack_use())
                 return 0;
 
-        /* Path must be in /dev */
-        if (!path_startswith(path, "/dev"))
-                return 0;
+        /* Path must be in /dev. Note that this check is pretty sloppy, as we might be called with non-normalized paths
+         * and hence not detect all cases of /dev. */
+
+        if (path_is_absolute(path)) {
+                if (!path_startswith(path, "/dev"))
+                        return 0;
+        } else {
+                _cleanup_free_ char *cwd = NULL;
+
+                r = safe_getcwd(&cwd);
+                if (r < 0)
+                        return r;
+
+                if (!path_startswith(cwd, "/dev"))
+                        return 0;
+        }
 
         fd = open(path, O_NOFOLLOW|O_CLOEXEC|O_PATH);
         if (fd < 0) {
@@ -253,7 +251,7 @@ int mac_smack_apply_pid(pid_t pid, const char *label) {
 }
 #endif // 0
 
-int mac_smack_fix(const char *path, bool ignore_enoent, bool ignore_erofs) {
+int mac_smack_fix(const char *path, LabelFixFlags flags) {
         return 0;
 }