[vhffs-dev] [1592] fixed soda's english, improved checks for svn and hg

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1592
Author:   gradator
Date:     2010-04-10 01:38:28 +0200 (Sat, 10 Apr 2010)
Log Message:
-----------
fixed soda's english, improved checks for svn and hg

Modified Paths:
--------------
    trunk/vhffs-shells/tuxshell.c

Modified: trunk/vhffs-shells/tuxshell.c
===================================================================
--- trunk/vhffs-shells/tuxshell.c	2010-04-08 21:54:02 UTC (rev 1591)
+++ trunk/vhffs-shells/tuxshell.c	2010-04-09 23:38:28 UTC (rev 1592)
@@ -35,6 +35,7 @@
 #include <syslog.h>
 #include <pwd.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <errno.h>
 
 /* grap is a wrapper designed to verify commands before passing them to system()
@@ -64,8 +65,8 @@
    Undefine any of these to not use them.
 */
 
-#define	OPTION_ARGC		1
-#define ARGS_ARGC		2
+#define	OPTION_ARGC 1
+#define ARGS_ARGC 2
 
 #define	ARGS_ARE_SINGLE_STRING
 
@@ -78,26 +79,27 @@
    shell special chars such as & ; , etc.
 */
 
-#define MAXSTRLEN		256		/* maximum single string length
+#define MAXSTRLEN 256		/* maximum single string length
 						   (no max on final command) */
 /* Define what strings are acceptable in <option> */
-char *options[] = 		{ "-c" , "-e" , NULL };
+char *options[] = { "-c" , "-e" , NULL };
 
 /* Define what strings are acceptable in <command>
    define an optional execution path CMD_PATH if desired */
 char *commands[][8] =	{ 
-							{"cvs" , "server" , NULL },
-							{"svnserve" , NULL },
-							{"git-upload-pack" , NULL },
-							{"git-fetch-pack" , NULL },
-							{"git-receive-pack" , NULL },
-							{"git-send-pack" , NULL },
-							{"hg" , NULL },
-							{NULL}
-						};
+	{"cvs" , "server" , NULL },
+	{"svnserve" , "-t" , NULL },
+	{"git-upload-pack" , NULL },
+	{"git-fetch-pack" , NULL },
+	{"git-receive-pack" , NULL },
+	{"git-send-pack" , NULL },
+	{"hg" , "-R" , NULL },
+	{NULL}
+};
+
 char **line; 
 int k;
-#define MAXARGS		256
+#define MAXARGS	256
 
 
 void deny()
@@ -109,9 +111,9 @@
 	exit(1);
 }
 
-#define	GRAP_TRUE		1
-#define GRAP_FALSE		0
-#define CMD_POS			0
+#define	GRAP_TRUE 1
+#define GRAP_FALSE 0
+#define CMD_POS	 0
 
 int main(int argc, char *argv[])
 {
@@ -123,11 +125,11 @@
 	struct passwd *cuser;
 	char *username;	
 
-	openlog("Tuxshell" , LOG_NOWAIT | LOG_NDELAY , LOG_AUTHPRIV );
+	openlog("tuxshell" , LOG_NOWAIT | LOG_NDELAY , LOG_AUTHPRIV );
 
-	ok			=	0;
-	uid		 	= 	getuid();
-	cuser		= 	getpwuid(uid);
+	ok = 0;
+	uid = getuid();
+	cuser = getpwuid(uid);
 
 	if( cuser == NULL )
 	{
@@ -136,15 +138,14 @@
 	}
 
 	/* Get username */
-	username	=	cuser->pw_name;
+	username = cuser->pw_name;
 
 	if(argc != 3) {
-		syslog( LOG_INFO , "user %s try open a login shell" , username );
+		syslog( LOG_INFO , "user %s tried to open a login shell" , username );
 		closelog();
 		deny();
 	}
 
-
 	/* process the initial option (see options array) */
 	i = -1;
 	while((options[++i] != NULL) && strcmp(options[i], argv[OPTION_ARGC]));
@@ -154,7 +155,7 @@
 		closelog();
 		deny();
 	}
-	
+
 	/* break single command and args string into seperate strings
 	   in a char** for execvp() to use */
 
@@ -182,8 +183,8 @@
 	/* check the command to insure it's in the acceptance list */
 	while( commands[i] != NULL )
 	{
-		line 	= 	commands[i];
-		k		=	-1;
+		line = commands[i];
+		k = -1;
 
 		if( line[0] == NULL )
 		{
@@ -203,13 +204,12 @@
 
 	if( ok == 0 ) 
 	{
-		/* printf("FATAL: %s bailed because command didn't qualify.\n", args[CMD_POS]); */
-		syslog( LOG_WARNING , "NOT allow command %s for user %s" , args[CMD_POS] , username );
+		syslog( LOG_WARNING , "denied command %s for user %s" , args[CMD_POS] , username );
 		closelog();
 		deny();
 	}
 
-	syslog( LOG_INFO , "allow command %s for user %s" , args[CMD_POS] , username );
+	syslog( LOG_INFO , "allowed command %s for user %s" , args[CMD_POS] , username );
 	closelog();
 
 	/* remove quotes of pathname (needed for git) */
@@ -222,6 +222,5 @@
 	umask (02);
 
 	/* ok, the command is clear, exec() it */
-
 	return (execvp(args[CMD_POS], args));
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/