發表文章

目前顯示的是 6月, 2020的文章

權限設定 apache

# visudo -f /etc/sudoers 增加 apache ALL=NOPASSWD: /backups/script.sh  /backups/script.sh針對這檔案不需要密碼 ----------------- 網頁 <?php $dirPath = '../../backup'; if (is_dir($dirPath)) {     $dir = opendir($dirPath);     while ($file = readdir($dir)) {         if (preg_match("/.ldif/i", $file)) {             echo '<a href="?file=' . $file . '">' . $file . '</a>';             echo '<br>';         }     }     closedir($dir); } if (isset($_GET['file'])) {     $result = shell_exec('sudo ../../../../backups/script.sh' . ' ' . $_GET['file'] . ' 2>&1');     echo $result; }