chiark / gitweb /
tree-wide: drop 'This file is part of systemd' blurb
[elogind.git] / src / basic / user-util.c
index f7b2a7c9d9e8d663ca07d7a389ca023d26baaafc..b3e4ce503b1bcd758438886ca3c2c33ee16b046a 100644 (file)
@@ -1,21 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
   Copyright 2010 Lennart Poettering
-
-  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 <alloca.h>
@@ -237,8 +222,7 @@ int get_user_creds_clean(
             (isempty(*shell) || is_nologin_shell(*shell)))
                 *shell = NULL;
 
-        if (home &&
-            (isempty(*home) || path_equal(*home, "/")))
+        if (home && empty_or_root(*home))
                 *home = NULL;
 
         return 0;
@@ -797,14 +781,11 @@ int fgetpwent_sane(FILE *stream, struct passwd **pw) {
 
         errno = 0;
         p = fgetpwent(stream);
-        if (p == NULL) {
-                if (errno == ENOENT)
-                        return false;
+        if (!p && errno != ENOENT)
                 return errno > 0 ? -errno : -EIO;
-        }
 
         *pw = p;
-        return true;
+        return !!p;
 }
 
 int fgetspent_sane(FILE *stream, struct spwd **sp) {
@@ -815,14 +796,11 @@ int fgetspent_sane(FILE *stream, struct spwd **sp) {
 
         errno = 0;
         s = fgetspent(stream);
-        if (s == NULL) {
-                if (errno == ENOENT)
-                        return false;
+        if (!s && errno != ENOENT)
                 return errno > 0 ? -errno : -EIO;
-        }
 
         *sp = s;
-        return true;
+        return !!s;
 }
 
 int fgetgrent_sane(FILE *stream, struct group **gr) {
@@ -833,14 +811,11 @@ int fgetgrent_sane(FILE *stream, struct group **gr) {
 
         errno = 0;
         g = fgetgrent(stream);
-        if (g == NULL) {
-                if (errno == ENOENT)
-                        return false;
+        if (!g && errno != ENOENT)
                 return errno > 0 ? -errno : -EIO;
-        }
 
         *gr = g;
-        return true;
+        return !!g;
 }
 
 #if ENABLE_GSHADOW
@@ -852,13 +827,10 @@ int fgetsgent_sane(FILE *stream, struct sgrp **sg) {
 
         errno = 0;
         s = fgetsgent(stream);
-        if (s == NULL) {
-                if (errno == ENOENT)
-                        return false;
+        if (!s && errno != ENOENT)
                 return errno > 0 ? -errno : -EIO;
-        }
 
         *sg = s;
-        return true;
+        return !!s;
 }
 #endif