Репозитории ALT
5.1: | 3.6.4-alt2.rel3.2 |
4.1: | 3.6.4-alt2.rel3 |
4.0: | 3.6.1-alt1 |
3.0: | |
+backports: | 3.0-alt0.M30.4 |
Группа :: Система/Серверы
Пакет: ss5
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: ss5-pidfilesupport.patch
Скачать
Скачать
diff -ruN ss5-3.6.1.orig/include/SS5Main.h ss5-3.6.1/include/SS5Main.h
--- ss5-3.6.1.orig/include/SS5Main.h 2006-08-25 00:55:21 +0400
+++ ss5-3.6.1/include/SS5Main.h 2006-10-06 18:15:51 +0400
@@ -225,6 +225,7 @@
#define MAXPREFORKPROCS 5000 /* Max number of preforked processes */
#define MAXPREFORKPROCLIFE 2048 /* Max number of requests a preforked process can servs */
#define MAXPEERS 12 /* Max number of network interfaces */
+#define MAXPATHLEN 4096 /* Max length of pathname */
enum ERR_SS5 { ERR = 0,
OK = 1 };
@@ -271,6 +272,8 @@
FILE *S5PeerFile;
+FILE *S5PidFile;
+
char S5ConfigFile[128];
char S5PeersFile[128];
char S5PasswordFile[128];
@@ -279,6 +282,7 @@
char S5ProfilePath[128];
char S5LoggingFile[128];
char S5RepKey[16];
+char S5PidFileName[MAXPATHLEN];
struct _SS5Peer {
char IP[16];
diff -ruN ss5-3.6.1.orig/src/SS5Main.c ss5-3.6.1/src/SS5Main.c
--- ss5-3.6.1.orig/src/SS5Main.c 2006-08-22 19:57:45 +0400
+++ ss5-3.6.1/src/SS5Main.c 2006-10-06 18:30:14 +0400
@@ -48,6 +48,12 @@
char socksUser[32] = SS5_DEFAULT_USER;
pid_t childPid;
+
+ extern char S5PidFileName[MAXPATHLEN];
+ extern FILE *S5PidFile;
+
+ strcpy(S5PidFileName,"/var/run/ss5/ss5.pid");
+ S5PidFile=NULL;
/*
* Initialize server static data to default values
@@ -166,6 +172,20 @@
count++;
}
break;
+ case 'p':
+ if (!argv[count+1])
+ S5Usage();
+ /*
+ * Set pid file
+ */
+ if((strlen(argv[count+1])+1)>MAXPATHLEN)
+ {
+ fprintf(stderr,"Too long pid file name\n");
+ S5ServerClose(EXIT);
+ }
+ strcpy(S5PidFileName,argv[count+1]);
+ count++;
+ break;
default: S5Usage(); break;
}
}
@@ -222,6 +242,24 @@
*/
if( !S5ServerMake(socksAddr, atoi(socksPort)) )
S5ServerClose(EXIT);
+
+ /*
+ * Create pidfile and exit if can't
+ */
+ umask(022);
+ S5PidFile=fopen(S5PidFileName,"w");
+ umask(0);
+ if (S5PidFile == NULL)
+ {
+ fprintf(stderr,"[ERRO] Can't create pid file %s\n",S5PidFileName);
+ S5ServerClose(EXIT);
+ }
+ if (fprintf(S5PidFile,"%d",(int)getpid())<=0)
+ {
+ fprintf(stderr,"[ERRO] Can't write to pid file %s\n",S5PidFileName);
+ S5ServerClose(EXIT);
+ }
+ fclose(S5PidFile);
/*
* Ignore signal when child die
diff -ruN ss5-3.6.1.orig/src/SS5Server.c ss5-3.6.1/src/SS5Server.c
--- ss5-3.6.1.orig/src/SS5Server.c 2006-08-22 16:42:51 +0400
+++ ss5-3.6.1/src/SS5Server.c 2006-10-06 18:30:49 +0400
@@ -106,6 +106,7 @@
if( VERBOSE() )
SS5Modules.mod_logging.Logging("[VERB] SS5 exiting.");
+ unlink(S5PidFileName);
exit(0);
}
return OK;
diff -ruN ss5-3.6.1.orig/src/SS5Utils.c ss5-3.6.1/src/SS5Utils.c
--- ss5-3.6.1.orig/src/SS5Utils.c 2006-08-25 01:03:50 +0400
+++ ss5-3.6.1/src/SS5Utils.c 2006-10-06 18:26:49 +0400
@@ -1171,6 +1171,7 @@
fprintf(stderr, "[INFO] [-b] Bind interface.\n");
fprintf(stderr, "[INFO] [-c] Run syntax check for config file.\n");
fprintf(stderr, "[INFO] [-m] No logging.\n");
+ fprintf(stderr, "[INFO] [-p] PID file pathname.\n");
fprintf(stderr, "[INFO] Modules:\n");
fprintf(stderr, "[INFO] mod_socks5: required\n");
fprintf(stderr, "[INFO] mod_authen: required\n");