0006-Remove-one-of-the-2-pidfiles-pidfilename-or-linkpidf.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 8a17acdd63ae2b2726dc5a3272b23294f75a5883 Mon Sep 17 00:00:00 2001
  2. From: Mike Frysinger <vapier@gentoo.org>
  3. Date: Tue, 5 Jan 2021 11:29:29 +0100
  4. Subject: [PATCH 06/14] Remove one of the 2 pidfiles (pidfilename or
  5. linkpidfile)
  6. ---
  7. pppd/auth.c | 2 +-
  8. pppd/main.c | 25 ++++++++++++++++---------
  9. pppd/multilink.c | 2 +-
  10. pppd/pppd.h | 3 ++-
  11. 4 files changed, 20 insertions(+), 12 deletions(-)
  12. diff --git a/pppd/auth.c b/pppd/auth.c
  13. index b1271c4..a1a831e 100644
  14. --- a/pppd/auth.c
  15. +++ b/pppd/auth.c
  16. @@ -678,7 +678,7 @@ link_terminated(int unit)
  17. * we delete its pid file.
  18. */
  19. if (!doing_multilink && !demand)
  20. - remove_pidfiles();
  21. + remove_pidfile(pidfilename);
  22. /*
  23. * If we may want to bring the link up again, transfer
  24. diff --git a/pppd/main.c b/pppd/main.c
  25. index 6c0a173..08c5306 100644
  26. --- a/pppd/main.c
  27. +++ b/pppd/main.c
  28. @@ -130,7 +130,7 @@ struct channel *the_channel;
  29. char *progname; /* Name of this program */
  30. char hostname[MAXNAMELEN]; /* Our hostname */
  31. -static char pidfilename[MAXPATHLEN]; /* name of pid file */
  32. +char pidfilename[MAXPATHLEN]; /* name of pid file */
  33. static char linkpidfile[MAXPATHLEN]; /* name of linkname pid file */
  34. char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
  35. uid_t uid; /* Our real user-id */
  36. @@ -241,6 +241,7 @@ static void chld(int);
  37. static void toggle_debug(int);
  38. static void open_ccp(int);
  39. static void bad_signal(int);
  40. +static void remove_pidfilenames(void);
  41. static void holdoff_end(void *);
  42. static void forget_child(int pid, int status);
  43. static int reap_kids(void);
  44. @@ -828,16 +829,22 @@ create_linkpidfile(int pid)
  45. }
  46. /*
  47. - * remove_pidfile - remove our pid files
  48. + * remove_pidfile - remove one of the 2 pidfiles (pidfilename or linkpidfile)
  49. */
  50. -void remove_pidfiles(void)
  51. +void remove_pidfile(char* filename)
  52. {
  53. - if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT)
  54. - warn("unable to delete pid file %s: %m", pidfilename);
  55. - pidfilename[0] = 0;
  56. - if (linkpidfile[0] != 0 && unlink(linkpidfile) < 0 && errno != ENOENT)
  57. - warn("unable to delete pid file %s: %m", linkpidfile);
  58. - linkpidfile[0] = 0;
  59. + if (filename[0] != 0 && unlink(filename) < 0 && errno != ENOENT)
  60. + warn("unable to delete pid file %s: %m", filename);
  61. + filename[0] = 0;
  62. +}
  63. +
  64. +/*
  65. + * remove_pidfiles - remove our pid files
  66. + */
  67. +static void remove_pidfiles()
  68. +{
  69. + remove_pidfile(pidfilename);
  70. + remove_pidfile(linkpidfile);
  71. }
  72. /*
  73. diff --git a/pppd/multilink.c b/pppd/multilink.c
  74. index ddd848c..c9d93c3 100644
  75. --- a/pppd/multilink.c
  76. +++ b/pppd/multilink.c
  77. @@ -267,7 +267,7 @@ void mp_bundle_terminated(void)
  78. notice("Connection terminated.");
  79. print_link_stats();
  80. if (!demand) {
  81. - remove_pidfiles();
  82. + remove_pidfile(pidfilename);
  83. script_unsetenv("IFNAME");
  84. }
  85. diff --git a/pppd/pppd.h b/pppd/pppd.h
  86. index bdb8778..88a1209 100644
  87. --- a/pppd/pppd.h
  88. +++ b/pppd/pppd.h
  89. @@ -219,6 +219,7 @@ extern int hungup; /* Physical layer has disconnected */
  90. extern int ifunit; /* Interface unit number */
  91. extern char ifname[]; /* Interface name */
  92. extern char hostname[]; /* Our hostname */
  93. +extern char pidfilename[]; /* name of pid file */
  94. extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
  95. extern int devfd; /* fd of underlying device */
  96. extern int fd_ppp; /* fd for talking PPP */
  97. @@ -531,7 +532,7 @@ void notify(struct notifier *, int);
  98. int ppp_send_config(int, int, u_int32_t, int, int);
  99. int ppp_recv_config(int, int, u_int32_t, int, int);
  100. const char *protocol_name(int);
  101. -void remove_pidfiles(void);
  102. +void remove_pidfile(char *);
  103. void lock_db(void);
  104. void unlock_db(void);
  105. --
  106. 2.30.0