Files
resatennis_tyroltenn/IDrive/.config/updateNasPasswd_cli.php

22 lines
513 B
PHP
Executable File

<?php
//error_reporting(0);
$curNASUser = $argv[1];
$content = file('/etc/passwd');
$updated = false;
$newContent = '';
foreach($content as $userInfo) {
$accessPerms = explode(':', $userInfo);
if(trim($accessPerms[0]) == $curNASUser) {
if(trim($accessPerms[6]) == '/sbin/nologin') {
$userInfo = str_replace('/sbin/nologin','/bin/sh',$userInfo);
$updated = true;
}
}
$newContent .= $userInfo;
}
if($updated){
if(!file_put_contents('/etc/passwd',$newContent))
$updated = false;
}
print $updated;
?>