รีสตาร์ทเซิร์ฟเวอร์ tomcat ที่ไม่ใช่รูท


1

ข้อมูล: Apache Tomcat / 6.0.36 CentOS 2.6.32-279.14.1.el6.x86_64

เป็นไปได้ไหม? ฉันได้ยินจากคนที่ Tomcat รุ่นเก่ากว่ามีเครื่องมือจัดการที่อนุญาตให้ผู้ใช้ที่ไม่มีสิทธิพิเศษรีสตาร์ทเซิร์ฟเวอร์ ฉันตรวจสอบผู้จัดการ แต่ฉันเห็นเฉพาะตัวเลือกเพื่อปิดใช้งานแอปพลิเคชันที่ทำงานบนเซิร์ฟเวอร์ แต่เป็นเซิร์ฟเวอร์เอง

คำตอบ:


0

ฉันตัดสินสำหรับวิธีแก้ปัญหา setuid ที่อธิบายไว้ใน Tomcat wiki

Another method is to use SetUID scripts (assuming you have the capability) to do this. Here's how I do it.

Create a file called foo.c with this content (replace "/path/startupscript" with the tomcat startup script):

#include <unistd.h> #include <stdlib.h>

int main( int argc, char *argv[] ) {

if ( setuid( 0 ) != 0 ) perror( "setuid() error" ); printf( "Starting ${APPLICATION}\n" ); execl( "/bin/sh", "sh", "/path/startupscript", 0 ); return 1; 

}

Run the following as root (replacing tmp with whatever you want the startup script to be and replacing XXXXX with whatever group you want to be able to start and stop tomcat:

gcc tmp.c -o tmp chown root:XXXXX tmp chmod ugo-rwx tmp chmod u+rwxs,g+rx tmp

Now members of the tomcat group should be able to start and stop tomcat. One caveat though, you need to ensure that that your tomcat startup script is not writable by anyone other than root, otherwise your users will be able to insert commands into the script and have them run as root (very big security hole).

แหล่งที่มา: http://wiki.apache.org/tomcat/HowTo#How_to_run_Tomcat_without_root_privileges.3F

โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.