Prechádzať zdrojové kódy

User/group setup fixes, other minor fixes.

John C. Frickson 9 rokov pred
rodič
commit
81cff32180
3 zmenil súbory, kde vykonal 43 pridanie a 14 odobranie
  1. 9 10
      Makefile.in
  2. 2 2
      src/check_nrpe.c
  3. 32 2
      uninstall.in

+ 9 - 10
Makefile.in

@@ -115,6 +115,9 @@ install-init:
 		$(INSTALL) -m 644 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
 		echo initctl reload-configuration; \
 		initctl reload-configuration; \
+	elif test $(INIT_TYPE) = systemd; then\
+		echo $(INSTALL) -m 644 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
+		$(INSTALL) -m 644 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
 	else\
 		echo $(INSTALL) -m 755 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
 		$(INSTALL) -m 755 startup/$(SRC_INIT) $(INIT_DIR)/$(INIT_FILE); \
@@ -127,15 +130,13 @@ install-config:
 install-group:
 	@if test $(OPSYS) = aix; then\
 		mkgroup $(GRPID);\
-	elif test $(OPSYS) = hpux; then\
-		groupadd $(GRPID);\
-	elif test $(OPSYS) = solaris; then\
+	elif test $(OPSYS) = hpux -o $(OPSYS) = solaris; then\
 		groupadd $(GRPID);\
 	elif test $(OPSYS) = osx; then\
 		newid=`dscl . -list /Groups gid | tr -s ' ' | cut -d' ' -f2 | sort -n | tail -1`;\
-		newid=$((newid + 1));\
+		newid=`expr 1 + $newid`;\
 		dscl . -create /Groups/$(GRPID) gid $$newid;\
-	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd; then\
+	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd"; then\
 		pw add group $(GRPID);\
 	else\
 		groupadd -r $(GRPID);\
@@ -144,17 +145,15 @@ install-group:
 install-user:
 	@if test $(OPSYS) = aix; then\
 		useradd -g $(GRPID) $(USERID);\
-	elif test $(OPSYS) = hpux; then\
-		useradd -g $(GRPID) $(USERID);\
-	elif test $(OPSYS) = solaris; then\
+	elif test $(OPSYS) = hpux -o $(OPSYS) = solaris; then\
 		useradd -g $(GRPID) $(USERID);\
 	elif test $(OPSYS) = osx; then\
 		newid=`dscl . -list /Users UniqueID | tr -s ' ' | cut -d' ' -f2 | sort -n | tail -1`;\
-		newid=$((newid + 1));\
+		newid=`expr 1 + $newid`;\
 		dscl . -create /Users/$(USERID);\
 		dscl . -create /Users/$(USERID) UniqueID $$newid;\
 		dscl . -append /Groups/$(GRPID) GroupMembership $(USERID);\
-	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd; then\
+	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd"; then\
 		pw add user -g $(GRPID) $(USERID);\
 	else\
 		useradd -r -g $(GRPID) $(USERID);\

+ 2 - 2
src/check_nrpe.c

@@ -190,7 +190,7 @@ int process_arguments(int argc, char **argv)
 	if (argc < 2)
 		return ERROR;
 
-	snprintf(optchars, MAX_INPUT_BUFFER, "H:b:c:a:t:p:S:L:C:K:A:d::s:46hlnuV");
+	snprintf(optchars, MAX_INPUT_BUFFER, "H:b:c:a:t:p:S:L:C:K:A:d::s:246hlnuV");
 
 	while (1) {
 #ifdef HAVE_GETOPT_LONG
@@ -1087,7 +1087,7 @@ int verify_callback(int preverify_ok, X509_STORE_CTX * ctx)
 
 void alarm_handler(int sig)
 {
-	const char msg[] = "CHECK_NRPE: Socket timeout";
+	const char msg[] = "CHECK_NRPE: Socket timeout\n";
 	write(STDOUT_FILENO, msg, sizeof(msg) - 1);
 	exit(timeout_return_code);
 }

+ 32 - 2
uninstall.in

@@ -1,6 +1,7 @@
 #!/bin/sh
 
 # Initialize variables
+myname="$0"
 quiet=0
 prompt=0
 verb=0
@@ -15,6 +16,8 @@ redir=1
 
 # Set file and path names
 NAME=@PKG_NAME@
+OPSYS=@opsys@
+DIST=@dist_type@
 SBINDIR=@sbindir@
 LIBEXECDIR=@libexecdir@
 PLUGINSDIR=@pluginsdir@
@@ -294,14 +297,41 @@ rm_config () {
 }
 
 rm_user () {
-#USERID=@nrpe_user@
+	prt_msg 1 0 0 "*** Removing user $(USERID)"
+	prt_msg 2 0 1 "Delete $(USERID)" || return
+
+	if test $(OPSYS) = aix; then
+		rmuser -p $(USERID)
+	elif test $(OPSYS) = osx; then
+		dscl . -delete /Groups/$(GRPID) GroupMembership $(USERID)
+		dscl . -delete /Users name $(USERID)
+	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd"; then
+		pw del user $(USERID)
+	else
+		userdel $(USERID)
+	fi
 }
 
 rm_group () {
-#GRPID=@nrpe_group@
+	prt_msg 1 0 0 "*** Removing group $(GROUPID)"
+	prt_msg 2 0 1 "Delete $(GROUPID)" || return
+
+	if test $(OPSYS) = aix; then
+		rmgroup -p $(GRPID)
+	elif test $(OPSYS) = osx; then
+		dscl . -delete /Groups/$(GRPID)
+	elif test $(OPSYS) = "bsd" -a $(DIST) = "freebsd"; then
+		pw del group $(GRPID)
+	else
+		groupdel $(GRPID)
+	fi
 }
 
 rm_script () {
+	prt_msg 1 0 0 "*** Removing $(myname)"
+	prt_msg 2 0 1 "Delete $(myname)" || return
+
+    rm "$(myname)"
 }
 
 get_opts $@