Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-flock / stx-integ / files / ibsh / ibsh-0.3e-cgcs.patch
1 Index: cgcs-users-1.0-r0/main.c
2 ===================================================================
3 --- cgcs-users-1.0-r0.orig/main.c
4 +++ cgcs-users-1.0-r0/main.c
5 @@ -37,6 +37,7 @@
6  
7  /* Header files */
8  #include "ibsh.h"
9 +#include "stdlib.h"
10  
11  /* Main: */
12  /* Handle arguments, read config files, start command processing. */
13 @@ -57,13 +58,28 @@
14  /* use our builtin code, otherwise use execve. After execve, check if the user didnt */
15  /* use the last command to create some illegal content. If yes, erase that. Give the */
16  /* notice only afterwards. */
17 +
18 +void ALRMhandler(int sig) {
19 +    OPENLOG;
20 +    syslog(LOG_INFO, "CLI timeout, user %s has logged out.", loggedin.uname);
21 +    CLOSELOG;
22 +    exit(0);
23 +}
24 +
25  int main(int argc, char **argv)
26  {
27    char temp[STRING_SIZE], *buf;
28    struct stat info;
29    uid_t ruid, euid;
30    gid_t rgid, egid;
31 +  unsigned int tout_cli = 0;
32  
33 +  const char* tout = getenv("TMOUT");
34 +  if (tout)
35 +    tout_cli = atoi(tout);
36 +  else
37 +    //default to 5 mins
38 +    tout_cli = 300;
39  
40    /* setuid protection */
41    ruid = getuid();
42 @@ -107,6 +123,7 @@ int main(int argc, char **argv)
43    signal( SIGQUIT, SIG_IGN );
44    signal( SIGTERM, SIG_IGN );
45    signal( SIGTSTP, SIG_IGN );
46 +  signal( SIGALRM, ALRMhandler );
47    LoadConfig();
48  
49    /* Command mode */
50 @@ -144,6 +161,7 @@ int main(int argc, char **argv)
51    /* will be allowed to run, unless it is mentioned in the */
52    /* config files. Files that are created with an extension */
53    /* that is listed in the other config file, must be deleted! */
54 +  alarm(tout_cli);
55    for ( ; ; ) {
56      /* Where is he ? */
57      getcwd(real_path, STRING_SIZE);
58 @@ -153,12 +171,12 @@ int main(int argc, char **argv)
59      }
60      /* We don't want the user to know where he actually is. */
61      /* This is the prompt! */
62 -    printf("[%s]%% ", jail_path);
63 +    printf("[%s]%% ", loggedin.uname);
64      /* scanf("%s", user_command); */
65      myscanf(user_command, real_path);
66 +    alarm(tout_cli);
67      /* Command interpretation and execution. */
68      if ( (CommandOK(user_command, loggedin.udir, jail_path, filtered_command)) == 0 ) {
69 -        printf("Sorry, can't let you do that!\n");
70          log_attempt(loggedin.uname);  /* v0.2a */
71          continue;
72      }
73 Index: cgcs-users-1.0-r0/config.c
74 ===================================================================
75 --- cgcs-users-1.0-r0.orig/config.c
76 +++ cgcs-users-1.0-r0/config.c
77 @@ -166,7 +166,6 @@ int LoadConfig( void )
78                  // Delete '\n'
79                  tmp2[i][strlen(tmp2[i]) - 1] = '\0';
80                  strncpy(extensions[i],tmp2[i],strlen(tmp2[i]));
81 -                printf("EXTENSIONS %s\n",extensions[i]);
82                 i++;
83        }
84    }