mcbot needs a proper system account
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Thu, 25 Dec 2008 19:55:07 +0100
changeset 31 bbcb8a3366b4
parent 30 eed9f710ba3b
child 32 89fb9c6611ca
mcbot needs a proper system account mcbot used the nobody system account and changed some properties. This collides with the default selinux policiy and the new account mcbot solves this issue. committer: Markus Bröker <mbroeker@largo.homelinux.org>
debian/changelog
debian/dirs
debian/postinst
debian/postrm
debian/preinst
debian/rules
scripts/runbot
src/CMakeLists.txt
src/dbtool.c
src/main.c
src/parse.c
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-mcbot (0.96-3) unstable; urgency=low
+mcbot (0.97-1) unstable; urgency=low
 
   * Initial Release
   * the location of mcbot.cgi is stored in the db
@@ -28,5 +28,6 @@
   * Build Dependency Check improved.
   * Lintian Build Checks
   * command must be freed on error - makes valgrind happy
+  * mcbot needs a proper system account - nobody collides with selinux-policy
 
- -- Markus Broeker <mbroeker@largo.homelinux.org>  Sun, 24 Aug 2008 20:30:00 +0200
+ -- Markus Broeker <mbroeker@largo.homelinux.org>  Thu, 25 Dec 2008 20:00:00 +0200
--- a/debian/dirs
+++ b/debian/dirs
@@ -1,2 +1,2 @@
-var/lib/nobody/data
-var/lib/nobody
+var/lib/mcbot/data
+var/lib/mcbot
--- a/debian/postinst
+++ b/debian/postinst
@@ -20,23 +20,23 @@
 
 case "$1" in
     configure)
-	if [ ! -f /var/lib/nobody/data/mcbot.dat ];
+	if [ ! -f /var/lib/mcbot/data/mcbot.dat ];
 	then		
-		echo "Creating initial database in /var/lib/nobody/data";
+		echo "Creating initial database in /var/lib/mcbot/data";
 		dbtool -a -k 1 -v 1;
 		dbtool -d 1;
 	fi
 
-	if [ -f /var/lib/nobody/.mcbotrc.dpkg-old ];
+	if [ -f /var/lib/mcbot/.mcbotrc.dpkg-old ];
 	then
-		mv -f /var/lib/nobody/.mcbotrc.dpkg-old /var/lib/nobody/.mcbotrc;
+		mv -f /var/lib/mcbot/.mcbotrc.dpkg-old /var/lib/mcbot/.mcbotrc;
 	fi
 
-	echo "Changing ownership in /var/lib/nobody"
-	usermod -s /bin/bash -d /var/lib/nobody nobody
-	chown -R nobody:nogroup /var/lib/nobody
-	echo "Setting permissions for /var/lib/nobody/.mcbotrc to 600"
-	chmod 600 /var/lib/nobody/.mcbotrc
+	echo "Changing ownership in /var/lib/mcbot"
+	useradd -c "MCBOT" -s /bin/bash -d /var/lib/mcbot mcbot
+	chown -R mcbot:mcbot /var/lib/mcbot
+	echo "Setting permissions for /var/lib/mcbot/.mcbotrc to 600"
+	chmod 600 /var/lib/mcbot/.mcbotrc
 	echo "ENTER /etc/init.d/mcbot restart after editing .mcbotrc"
 	update-rc.d mcbot defaults &>/dev/null
 	invoke-rc.d mcbot restart
--- a/debian/postrm
+++ b/debian/postrm
@@ -21,14 +21,14 @@
 
 case "$1" in
     purge)
-	rm -rf /var/lib/nobody/data;
-	rm -f /var/lib/nobody/.mcbotrc;
-	rm -f /var/lib/nobody/mcbot-*.log;
+	rm -rf /var/lib/mcbot/data;
+	rm -f /var/lib/mcbot/.mcbotrc;
+	rm -f /var/lib/mcbot/mcbot-*.log;
     ;;
     
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
 	update-rc.d -f mcbot remove &>/dev/null
-	usermod -d /nonexistent -s /bin/bash nobody
+	userdel mcbot
 	;;
 	
     *)
--- a/debian/preinst
+++ b/debian/preinst
@@ -21,9 +21,9 @@
 		invoke-rc.d mcbot stop;
 	fi
 
-	if [ -f /var/lib/nobody/.mcbotrc ]; 
+	if [ -f /var/lib/mcbot/.mcbotrc ]; 
 	then
-		cp -f /var/lib/nobody/.mcbotrc /var/lib/nobody/.mcbotrc.dpkg-old
+		cp -f /var/lib/mcbot/.mcbotrc /var/lib/mcbot/.mcbotrc.dpkg-old
 	fi
     ;;
 
--- a/debian/rules
+++ b/debian/rules
@@ -48,7 +48,7 @@
 
 	# Add here commands to install the package into debian/mcbot.
 	$(MAKE) DESTDIR=$(CURDIR)/debian/mcbot install
-	cp config/.mcbotrc debian/mcbot/var/lib/nobody/
+	cp config/.mcbotrc debian/mcbot/var/lib/mcbot/
 
 # Build architecture-independent files here.
 binary-indep: build install
--- a/scripts/runbot
+++ b/scripts/runbot
@@ -10,12 +10,12 @@
 # Description:       IRC BOT mcbot
 ### END INIT INFO
 
-RUNAS="nobody"
+RUNAS="mcbot"
 BINARY="mcbot"
 DIRECTORY="/usr/sbin/"
 LANGUAGE="de_DE.UTF-8"
 PARAMETER=""
-LOGFILE="/var/lib/nobody/mcbot-`date \"+%d-%m-%y\"`.log"
+LOGFILE="/var/lib/mcbot/mcbot-`date \"+%d-%m-%y\"`.log"
 
 [[ ! -x "${DIRECTORY}/${BINARY}" ]] && exit 0
 
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,7 +10,7 @@
 # C-Definitions
 ADD_DEFINITIONS(-Wall -O2 -ansi -pedantic)
 ADD_DEFINITIONS(-D_XOPEN_SOURCE=500)
-ADD_DEFINITIONS(-DBOT_VERSION=0.96)
+ADD_DEFINITIONS(-DBOT_VERSION=0.97)
 
 # Includes
 INCLUDE_DIRECTORIES(../include)
@@ -22,7 +22,7 @@
 # Install Rules
 INSTALL(TARGETS mcbot RUNTIME DESTINATION /usr/sbin)
 INSTALL(TARGETS dbtool RUNTIME DESTINATION /usr/bin)
-INSTALL(DIRECTORY ../locale/ DESTINATION /var/lib/nobody/data/locale)
+INSTALL(DIRECTORY ../locale/ DESTINATION /var/lib/mcbot/data/locale)
 INSTALL(PROGRAMS ../scripts/runbot DESTINATION /etc/init.d/ 
 	RENAME mcbot)
 INSTALL(PROGRAMS ../scripts/mcbot.cgi DESTINATION /usr/lib/cgi-bin/)
--- a/src/dbtool.c
+++ b/src/dbtool.c
@@ -11,7 +11,7 @@
 #include <database.h>
 
 #ifndef FILE_NAME
-#define FILE_NAME "/var/lib/nobody/data/mcbot.dat"
+#define FILE_NAME "/var/lib/mcbot/data/mcbot.dat"
 #endif
 
 void help (char *prgname)
--- a/src/main.c
+++ b/src/main.c
@@ -16,11 +16,11 @@
 #include <config.h>
 
 #ifndef CONFIG_FILE
-#define CONFIG_FILE "/var/lib/nobody/.mcbotrc"
+#define CONFIG_FILE "/var/lib/mcbot/.mcbotrc"
 #endif
 
 #ifndef LOCALE_PATH
-#define LOCALE_PATH "/var/lib/nobody/data/locale"
+#define LOCALE_PATH "/var/lib/mcbot/data/locale"
 #endif
 
 short active = 1;               /* needed for a safe shutdown */
@@ -105,6 +105,7 @@
         } else {
             if ((msg = parse (&message)) != NULL) {
                 fprintf (message.stream, "%s\r\n", msg);
+                fflush (message.stream);
                 printf ("%10s %s", "WRITE", msg);
             }
         }
--- a/src/parse.c
+++ b/src/parse.c
@@ -16,7 +16,7 @@
 #include <libintl.h>
 
 #ifndef DATABASE_FILE
-#define DATABASE_FILE "/var/lib/nobody/data/mcbot.dat"
+#define DATABASE_FILE "/var/lib/mcbot/data/mcbot.dat"
 #endif
 
 #ifndef SOURCE_URL