_secure_path.c (91211) | _secure_path.c (121193) |
---|---|
1/*- 2 * Based on code copyright (c) 1995,1997 by 3 * Berkeley Software Design, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, is permitted provided that the following conditions 8 * are met: --- 6 unchanged lines hidden (view full) --- 15 * 3. This work was done expressly for inclusion into FreeBSD. Other use 16 * is permitted provided this notation is included. 17 * 4. Absolutely no warranty of function or purpose is made by the authors. 18 * 5. Modifications may be freely made to this file providing the above 19 * conditions are met. 20 */ 21 22#include <sys/cdefs.h> | 1/*- 2 * Based on code copyright (c) 1995,1997 by 3 * Berkeley Software Design, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, is permitted provided that the following conditions 8 * are met: --- 6 unchanged lines hidden (view full) --- 15 * 3. This work was done expressly for inclusion into FreeBSD. Other use 16 * is permitted provided this notation is included. 17 * 4. Absolutely no warranty of function or purpose is made by the authors. 18 * 5. Modifications may be freely made to this file providing the above 19 * conditions are met. 20 */ 21 22#include <sys/cdefs.h> |
23__FBSDID("$FreeBSD: head/lib/libutil/_secure_path.c 91211 2002-02-25 01:25:30Z bde $"); | 23__FBSDID("$FreeBSD: head/lib/libutil/_secure_path.c 121193 2003-10-18 10:04:16Z markm $"); |
24 25#include <sys/types.h> 26#include <sys/stat.h> 27 28#include <errno.h> 29#include <libutil.h> 30#include <stddef.h> 31#include <syslog.h> --- 22 unchanged lines hidden (view full) --- 54 r = -2; /* if it is just missing, skip the log entry */ 55 else 56 msg = "%s: cannot stat %s: %m"; 57 } 58 else if (!S_ISREG(sb.st_mode)) 59 msg = "%s: %s is not a regular file"; 60 else if (sb.st_mode & S_IWOTH) 61 msg = "%s: %s is world writable"; | 24 25#include <sys/types.h> 26#include <sys/stat.h> 27 28#include <errno.h> 29#include <libutil.h> 30#include <stddef.h> 31#include <syslog.h> --- 22 unchanged lines hidden (view full) --- 54 r = -2; /* if it is just missing, skip the log entry */ 55 else 56 msg = "%s: cannot stat %s: %m"; 57 } 58 else if (!S_ISREG(sb.st_mode)) 59 msg = "%s: %s is not a regular file"; 60 else if (sb.st_mode & S_IWOTH) 61 msg = "%s: %s is world writable"; |
62 else if (uid != -1 && sb.st_uid != uid && sb.st_uid != 0) { | 62 else if ((int)uid != -1 && sb.st_uid != uid && sb.st_uid != 0) { |
63 if (uid == 0) 64 msg = "%s: %s is not owned by root"; 65 else 66 msg = "%s: %s is not owned by uid %d"; | 63 if (uid == 0) 64 msg = "%s: %s is not owned by root"; 65 else 66 msg = "%s: %s is not owned by uid %d"; |
67 } else if (gid != -1 && sb.st_gid != gid && (sb.st_mode & S_IWGRP)) | 67 } else if ((int)gid != -1 && sb.st_gid != gid && (sb.st_mode & S_IWGRP)) |
68 msg = "%s: %s is group writeable by non-authorised groups"; 69 else 70 r = 0; 71 if (msg != NULL) 72 syslog(LOG_ERR, msg, "_secure_path", path, uid); 73 return r; 74} | 68 msg = "%s: %s is group writeable by non-authorised groups"; 69 else 70 r = 0; 71 if (msg != NULL) 72 syslog(LOG_ERR, msg, "_secure_path", path, uid); 73 return r; 74} |