Bug 5977

Summary: --pidfile option doesn't work
Product: ALT Linux 2.4 Reporter: Dmitry Vodennikov <vod>
Component: pptpdAssignee: Denis Ovsienko <pilot>
Status: CLOSED FIXED QA Contact: Andrey Cherepanov <cas>
Severity: normal    
Priority: P2    
Version: 2.4   
Hardware: all   
OS: Linux   
Attachments:
Description Flags
моя версия патча none

Description Dmitry Vodennikov 2005-01-27 09:27:09 MSK
--pidfile options for pptpd doesn't work, it always create default pidfile /var/
run/pptpd.pid
error in pptpd.c, function log_pid
here is small patch
--------------------------------------------------------------------------
--- poptop-1.1.4.orig/pptpd.c   2003-02-27 15:01:10 +0500
+++ poptop-1.1.4/pptpd.c        2005-01-27 11:02:22 +0500
@@ -76,7 +76,7 @@
 static void my_daemon(int argc, char **argv);
 #endif

-static void log_pid();
+static void log_pid(char *pid_file);
 static char *lookup(char *);

 static void showusage(char *prog)
@@ -347,21 +347,20 @@
        ledman_cmd(LEDMAN_CMD_ON, LEDMAN_VPN);
 #endif
        /* after we have our final pid... */
-       log_pid();
-
+       log_pid(pid_file);
+
        pptp_manager(argc, argv);
        return 1;
 }

-static void log_pid() {
+static void log_pid(char *pid_file) {
         FILE    *f;
         pid_t   pid;
-        char    *pidfile = "/var/run/pptpd.pid";

         pid = getpid();
-        if ((f = fopen(pidfile, "w")) == NULL) {
+        if ((f = fopen(pid_file, "w")) == NULL) {
                 syslog(LOG_ERR, "PPTPD: failed to open(%s), errno=%d\n",
-                        pidfile, errno);
+                        pid_file, errno);
                 return;
         }
         fprintf(f, "%d\n", pid);
--------------------------------------------------------------------------
Comment 1 Denis Ovsienko 2005-02-07 17:45:28 MSK
Created attachment 722 [details]
моя версия патча

Я думаю, будет лучше в таком виде.
Comment 2 Denis Ovsienko 2005-02-07 17:46:33 MSK
Реализовано в pptpd-1.1.4-alt4.b4
Comment 3 Dmitry Vodennikov 2005-02-07 19:21:25 MSK
(In reply to comment #1)
> Created an attachment (id=722) [edit]
> моя версия патча
> Я думаю, будет лучше в таком виде.

Да, так оно лучше.

По большому счету надо бы "/var/run/pptpd.pid" вообще в define вынести...