2 suPHP - (c)2002-2004 Sebastian Marsching <sebastian@marsching.com>
4 This file is part of suPHP.
6 suPHP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 suPHP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with suPHP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <sys/types.h>
28 int check_path(char *script_path)
30 char *document_root = getenv("DOCUMENT_ROOT");
33 suphp_log_error("Could not get DOCUMENT_ROOT from the environment processing %s", script_path);
34 error_msg_exit(ERRCODE_WRONG_ENVIRONMENT, "DOCUMENT_ROOT not set", __FILE__, __LINE__);
36 if (strncmp(document_root, script_path, strlen(document_root))!=0)
42 int check_permissions(char *script_path)
44 struct stat file_info;
46 if (stat(script_path, &file_info))
48 suphp_log_error("Could not stat() script %s", script_path);
49 error_sysmsg_exit(ERRCODE_UNKNOWN, "stat() failed", __FILE__, __LINE__);
52 if (!(file_info.st_mode & S_IRUSR))
54 suphp_log_error("Owner doesn't have read permission on %s", script_path);
58 if (file_info.st_mode & (S_IWGRP | S_IWOTH))
60 suphp_log_error("Script (%s) is writeable by others", script_path);