ソースを参照

Use stat instead of access to check for file existence

Guillem Jover 16 年 前
コミット
dde9a226d5
共有2 個のファイルを変更した5 個の追加2 個の削除を含む
  1. 3 1
      src/statcmd.c
  2. 2 1
      utils/start-stop-daemon.c

+ 3 - 1
src/statcmd.c

@@ -279,7 +279,9 @@ statoverride_add(const char *const *argv)
 	*filestat = statdb_node_new(user, group, mode);
 
 	if (opt_update) {
-		if (access(filename, F_OK) == 0)
+		struct stat st;
+
+		if (stat(filename, &st) == 0)
 			statdb_node_apply(filename, *filestat);
 		else if (opt_verbose)
 			warning(_("--update given but %s does not exist"),

+ 2 - 1
utils/start-stop-daemon.c

@@ -1494,6 +1494,7 @@ main(int argc, char **argv)
 	}
 	if (changeuser) {
 		struct passwd *pw;
+		struct stat st;
 
 		if (sscanf(changeuser, "%d", &runas_uid) == 1)
 			pw = getpwuid(runas_uid);
@@ -1507,7 +1508,7 @@ main(int argc, char **argv)
 			changegroup = ""; /* Just empty. */
 			runas_gid = pw->pw_gid;
 		}
-		if (access(pw->pw_dir, F_OK) == 0)
+		if (stat(pw->pw_dir, &st) == 0)
 			setenv("HOME", pw->pw_dir, 1);
 	}