Просмотр исходного кода

* Moved clear_tmp() to shell.c

svn: 666
Bryan Drewery 22 лет назад
Родитель
Сommit
b59c7c95b0
3 измененных файлов с 23 добавлено и 22 удалено
  1. 0 22
      src/main.c
  2. 22 0
      src/shell.c
  3. 1 0
      src/shell.h

+ 0 - 22
src/main.c

@@ -43,7 +43,6 @@
 #include <sys/ptrace.h>
 #include <sys/wait.h>
 #endif /* S_ANTITRACE */
-#include <dirent.h>
 #include <pwd.h>
 
 #include "chan.h"
@@ -201,27 +200,6 @@ void checkpass()
   }
 }
 
-int clear_tmp()
-{
-  DIR *tmp;
-  struct dirent *dir_ent;
-  if (!(tmp = opendir(tempdir))) return 1;
-  while ((dir_ent = readdir(tmp))) {
-    if (strncmp(dir_ent->d_name, ".pid.", 4) && strncmp(dir_ent->d_name, ".u", 2) && strcmp(dir_ent->d_name, ".bin.old")
-       && strcmp(dir_ent->d_name, ".") && strcmp(dir_ent->d_name, ".un") && strcmp(dir_ent->d_name, "..")) {
-      char *file = malloc(strlen(dir_ent->d_name) + strlen(tempdir) + 1);
-      file[0] = 0;
-      strcat(file, tempdir);
-      strcat(file, dir_ent->d_name);
-      file[strlen(file)] = 0;
-      unlink(file);
-      free(file);
-    }
-  }
-  closedir(tmp);
-  return 0;
-}
-
 void got_ed(char *which, char *in, char *out)
 {
   sdprintf(STR("got_Ed called: -%s i: %s o: %s"), which, in, out);

+ 22 - 0
src/shell.c

@@ -40,6 +40,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <dirent.h>
 
 
 extern struct cfg_entry CFG_LOGIN, CFG_BADPROCESS, CFG_PROCESSLIST, CFG_PROMISC,
@@ -117,6 +118,27 @@ int readconf()
   return 0;
 }
 
+int clear_tmp()
+{
+  DIR *tmp;
+  struct dirent *dir_ent;
+  if (!(tmp = opendir(tempdir))) return 1;
+  while ((dir_ent = readdir(tmp))) {
+    if (strncmp(dir_ent->d_name, ".pid.", 4) && strncmp(dir_ent->d_name, ".u", 2) && strcmp(dir_ent->d_name, ".bin.old")
+       && strcmp(dir_ent->d_name, ".") && strcmp(dir_ent->d_name, ".un") && strcmp(dir_ent->d_name, "..")) {
+      char *file = malloc(strlen(dir_ent->d_name) + strlen(tempdir) + 1);
+      file[0] = 0;
+      strcat(file, tempdir);
+      strcat(file, dir_ent->d_name);
+      file[strlen(file)] = 0;
+      unlink(file);
+      free(file);
+    }
+  }
+  closedir(tmp);
+  return 0;
+}
+
 
 #ifdef S_LASTCHECK
 char last_buf[128]="";

+ 1 - 0
src/shell.h

@@ -59,6 +59,7 @@ typedef struct conf_b {
 
 
 #ifndef MAKING_MODS
+int clear_tmp();
 void init_conf();
 void free_conf();
 int readconf();