c419174e73
The cgcs-users patches started to fail after the tarball download was enabled. This was because the indentation is different in the downloaded source code. In the past, ibsh was get from an internal repository and presumably this source code was modified before get checked in into the repo. Change-Id: I0b36bedc35a6002bd596c0d2bd6729ccb37285ae Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com> Signed-off-by: Scott Little <scott.little@windriver.com>
85 lines
2.6 KiB
Diff
85 lines
2.6 KiB
Diff
Index: cgcs-users-1.0-r0/main.c
|
|
===================================================================
|
|
--- cgcs-users-1.0-r0.orig/main.c
|
|
+++ cgcs-users-1.0-r0/main.c
|
|
@@ -37,6 +37,7 @@
|
|
|
|
/* Header files */
|
|
#include "ibsh.h"
|
|
+#include "stdlib.h"
|
|
|
|
/* Main: */
|
|
/* Handle arguments, read config files, start command processing. */
|
|
@@ -57,13 +58,28 @@
|
|
/* use our builtin code, otherwise use execve. After execve, check if the user didnt */
|
|
/* use the last command to create some illegal content. If yes, erase that. Give the */
|
|
/* notice only afterwards. */
|
|
+
|
|
+void ALRMhandler(int sig) {
|
|
+ OPENLOG;
|
|
+ syslog(LOG_INFO, "CLI timeout, user %s has logged out.", loggedin.uname);
|
|
+ CLOSELOG;
|
|
+ exit(0);
|
|
+}
|
|
+
|
|
int main(int argc, char **argv)
|
|
{
|
|
char temp[STRING_SIZE], *buf;
|
|
struct stat info;
|
|
uid_t ruid, euid;
|
|
gid_t rgid, egid;
|
|
+ unsigned int tout_cli = 0;
|
|
|
|
+ const char* tout = getenv("TMOUT");
|
|
+ if (tout)
|
|
+ tout_cli = atoi(tout);
|
|
+ else
|
|
+ //default to 5 mins
|
|
+ tout_cli = 300;
|
|
|
|
/* setuid protection */
|
|
ruid = getuid();
|
|
@@ -107,6 +123,7 @@ int main(int argc, char **argv)
|
|
signal( SIGQUIT, SIG_IGN );
|
|
signal( SIGTERM, SIG_IGN );
|
|
signal( SIGTSTP, SIG_IGN );
|
|
+ signal( SIGALRM, ALRMhandler );
|
|
LoadConfig();
|
|
|
|
/* Command mode */
|
|
@@ -144,6 +161,7 @@ int main(int argc, char **argv)
|
|
/* will be allowed to run, unless it is mentioned in the */
|
|
/* config files. Files that are created with an extension */
|
|
/* that is listed in the other config file, must be deleted! */
|
|
+ alarm(tout_cli);
|
|
for ( ; ; ) {
|
|
/* Where is he ? */
|
|
getcwd(real_path, STRING_SIZE);
|
|
@@ -153,12 +171,12 @@ int main(int argc, char **argv)
|
|
}
|
|
/* We don't want the user to know where he actually is. */
|
|
/* This is the prompt! */
|
|
- printf("[%s]%% ", jail_path);
|
|
+ printf("[%s]%% ", loggedin.uname);
|
|
/* scanf("%s", user_command); */
|
|
myscanf(user_command, real_path);
|
|
+ alarm(tout_cli);
|
|
/* Command interpretation and execution. */
|
|
if ( (CommandOK(user_command, loggedin.udir, jail_path, filtered_command)) == 0 ) {
|
|
- printf("Sorry, can't let you do that!\n");
|
|
log_attempt(loggedin.uname); /* v0.2a */
|
|
continue;
|
|
}
|
|
Index: cgcs-users-1.0-r0/config.c
|
|
===================================================================
|
|
--- cgcs-users-1.0-r0.orig/config.c
|
|
+++ cgcs-users-1.0-r0/config.c
|
|
@@ -166,7 +166,6 @@ int LoadConfig( void )
|
|
// Delete '\n'
|
|
tmp2[i][strlen(tmp2[i]) - 1] = '\0';
|
|
strncpy(extensions[i],tmp2[i],strlen(tmp2[i]));
|
|
- printf("EXTENSIONS %s\n",extensions[i]);
|
|
i++;
|
|
}
|
|
}
|