Remove chk_ssh
Because the behavior of the function doesn't change at all depending on whether a utmp entry is over ssh or not, the function which checks this is not needed, and has been removed.
This commit is contained in:
		
							parent
							
								
									696a3973f1
								
							
						
					
					
						commit
						42731b5ced
					
				
					 1 changed files with 0 additions and 31 deletions
				
			
		
							
								
								
									
										31
									
								
								timeoutd.c
									
										
									
									
									
								
							
							
						
						
									
										31
									
								
								timeoutd.c
									
										
									
									
									
								
							|  | @ -96,8 +96,6 @@ void logoff_msg(); | ||||||
| void killit(); | void killit(); | ||||||
| int chk_xsession();             /* seppy: is it a X-Session? */ | int chk_xsession();             /* seppy: is it a X-Session? */ | ||||||
| void killit_xsession();         /* seppy: kill the X-Session */ | void killit_xsession();         /* seppy: kill the X-Session */ | ||||||
| int chk_ssh(pid_t pid);         /* seppy: check if user is logged in via ssh (we have to
 |  | ||||||
|                                    handle that different... ;( */ |  | ||||||
| char *getusr(pid_t pid);        /*seppy: get the owner of a running process */ | char *getusr(pid_t pid);        /*seppy: get the owner of a running process */ | ||||||
| void segfault();                /* seppy: catch segfault and log them */ | void segfault();                /* seppy: catch segfault and log them */ | ||||||
| int chk_xterm();                /* seppy: is it a xterm? */ | int chk_xterm();                /* seppy: is it a xterm? */ | ||||||
|  | @ -964,19 +962,10 @@ char *host; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|     /* check if the pid is sshd. If so, get PID of the child process (another ssh, owned by the user).
 |  | ||||||
|        Test reverse if this child process is also ssh and owned by the user we want to log out. |  | ||||||
|        (because we don't want to slay another user ;) */ |  | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
|     syslog(LOG_NOTICE, "I am at killit() pid=%d user=%s line %d", pid, user, __LINE__); |     syslog(LOG_NOTICE, "I am at killit() pid=%d user=%s line %d", pid, user, __LINE__); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
|     if (chk_ssh(pid)) { |  | ||||||
| #ifdef DEBUG |  | ||||||
|         syslog(LOG_NOTICE, "User %s (pid:%d) logged in via ssh from %s.", user, pid, host); |  | ||||||
| #endif |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     logoff_msg(tty); |     logoff_msg(tty); | ||||||
|     sleep(KWAIT);               /*make sure msg does not get lost, again (esp. ssh) */ |     sleep(KWAIT);               /*make sure msg does not get lost, again (esp. ssh) */ | ||||||
|     close(tty); |     close(tty); | ||||||
|  | @ -1142,26 +1131,6 @@ char *host, *user; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| int chk_ssh(pid)                /* seppy; returns true if pid is sshd, otherwise it returns false */ |  | ||||||
| pid_t pid; |  | ||||||
| { |  | ||||||
|     sprintf(path, "/proc/%d/stat", pid); |  | ||||||
|     proc_file = fopen(path, "r"); |  | ||||||
|     if (!proc_file) { |  | ||||||
|         syslog(LOG_WARNING, "chk_ssh(): PID %d does not exist. Something went wrong. Ignoring.", |  | ||||||
|                pid); |  | ||||||
|         return 0; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     fscanf(proc_file, "%*d (%[^)]", comm); |  | ||||||
|     fclose(proc_file); |  | ||||||
| 
 |  | ||||||
|     if (!strcmp(comm, "sshd")) |  | ||||||
|         return 1; |  | ||||||
|     else |  | ||||||
|         return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| char *getusr(pid)               /*seppy; returns the name of the user owning process with the Process ID pid */ | char *getusr(pid)               /*seppy; returns the name of the user owning process with the Process ID pid */ | ||||||
| pid_t pid; | pid_t pid; | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Petar Kapris
						Petar Kapris