Cleanup changing user code in maintenance.php and account_manager.php.
This commit is contained in:
parent
33bff45270
commit
2eeb873a45
|
@ -4,17 +4,28 @@ chdir($spoolnews_path);
|
||||||
include "config.inc.php";
|
include "config.inc.php";
|
||||||
include "newsportal.php";
|
include "newsportal.php";
|
||||||
|
|
||||||
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
|
|
||||||
// Change to webserver user if root
|
// Change to webserver user if root
|
||||||
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
|
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
|
||||||
/* Change to non root user */
|
/* Change to non root user */
|
||||||
change_identity($uinfo["uid"], $uinfo["gid"]);
|
change_identity($uinfo["uid"], $uinfo["gid"]);
|
||||||
$processUser = posix_getpwuid(posix_geteuid());
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
||||||
echo "You are running as: " . $processUser['name'] . "\n";
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
echo 'Please run this scripts as: ' . $CONFIG['webserver_user'] . "\n";
|
echo 'Please run this script as: ' . $CONFIG['webserver_user'] . "\n";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
/* Everything below runs as $CONFIG['webserver_user'] */
|
/* Everything below runs as $CONFIG['webserver_user'] */
|
||||||
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
|
|
||||||
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
|
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
||||||
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
|
echo 'Please run this script as: ' . $CONFIG['webserver_user'] . "\n";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$keyfile = $spooldir . '/keys.dat';
|
$keyfile = $spooldir . '/keys.dat';
|
||||||
$keys = unserialize(file_get_contents($keyfile));
|
$keys = unserialize(file_get_contents($keyfile));
|
||||||
|
@ -128,7 +139,7 @@ function get_user_by_hash($postinghash)
|
||||||
echo "Hash file not found\n";
|
echo "Hash file not found\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(isset($posthash[$postinghash])) {
|
if (isset($posthash[$postinghash])) {
|
||||||
echo $posthash[$postinghash] . ' : ' . $postinghash . "\n";
|
echo $posthash[$postinghash] . ' : ' . $postinghash . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo "$postinghash not found in database\n";
|
echo "$postinghash not found in database\n";
|
||||||
|
|
|
@ -28,14 +28,18 @@ if (! isset($argv[1])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($argv[1] != '-newsection') {
|
if ($argv[1] != '-newsection') {
|
||||||
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
|
|
||||||
// Change to webserver user if root
|
// Change to webserver user if root
|
||||||
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
|
$uinfo = posix_getpwnam($CONFIG['webserver_user']);
|
||||||
/* Change to non root user */
|
/* Change to non root user */
|
||||||
change_identity($uinfo["uid"], $uinfo["gid"]);
|
change_identity($uinfo["uid"], $uinfo["gid"]);
|
||||||
$processUser = posix_getpwuid(posix_geteuid());
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
|
|
||||||
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
||||||
echo "You are running as: " . $processUser['name'] . "\n";
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
echo 'Please run this scripts as: ' . $CONFIG['webserver_user'] . "\n";
|
echo 'Please run this script as: ' . $CONFIG['webserver_user'] . "\n";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
/* Everything below runs as $CONFIG['webserver_user'] */
|
/* Everything below runs as $CONFIG['webserver_user'] */
|
||||||
|
@ -43,13 +47,12 @@ if ($argv[1] != '-newsection') {
|
||||||
|
|
||||||
$processUser = posix_getpwuid(posix_geteuid());
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
if ($processUser['name'] != $CONFIG['webserver_user']) {
|
||||||
echo "You are running as: " . $processUser['name'] . "\n";
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
echo 'Please run this scripts as: ' . $CONFIG['webserver_user'] . "\n";
|
echo 'Please run this script as: ' . $CONFIG['webserver_user'] . "\n";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$logfile = $logdir . '/import.log';
|
$logfile = $logdir . '/import.log';
|
||||||
|
|
||||||
$lockfile = $lockdir . '/' . $config_name . '-spoolnews.lock';
|
$lockfile = $lockdir . '/' . $config_name . '-spoolnews.lock';
|
||||||
|
|
||||||
$pid = file_get_contents($lockfile);
|
$pid = file_get_contents($lockfile);
|
||||||
|
@ -57,9 +60,12 @@ if ($argv[1] != '-newsection') {
|
||||||
print "Starting Import...\n";
|
print "Starting Import...\n";
|
||||||
file_put_contents($lockfile, getmypid()); // create lockfile
|
file_put_contents($lockfile, getmypid()); // create lockfile
|
||||||
} else {
|
} else {
|
||||||
print "Import currently running\n";
|
print "Spoolnews currently running\n";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$processUser = posix_getpwuid(posix_geteuid());
|
||||||
|
echo "You are running as user: " . $processUser['name'] . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($argv[1][0] == '-') {
|
if ($argv[1][0] == '-') {
|
||||||
|
|
Loading…
Reference in New Issue