Mailing List Archive

[PATCH] restore original cwd after vpnc_main_loop()
Signed-off-by: Dan Lenski <dlenski@gmail.com>
---
trunk/tunip.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/trunk/tunip.c b/trunk/tunip.c
index 00d9e1c..20e793a 100644
--- a/trunk/tunip.c
+++ b/trunk/tunip.c
@@ -985,6 +985,7 @@ void vpnc_doit(struct sa_block *s)
struct encap_method meth;

const char *pidfile = config[CONFIG_PID_FILE];
+ const char *cwd;

switch (s->ipsec.encap_mode) {
case IPSEC_ENCAP_TUNNEL:
@@ -1038,6 +1039,8 @@ void vpnc_doit(struct sa_block *s)
signal(SIGINT, killit);
signal(SIGTERM, killit);

+ /* save cwd */
+ cwd = get_current_dir_name();
chdir("/");

if (!opt_nd) {
@@ -1067,6 +1070,10 @@ void vpnc_doit(struct sa_block *s)

vpnc_main_loop(s);

+ /* restore cwd */
+ chdir(cwd);
+ free(cwd);
+
if (pidfile)
unlink(pidfile); /* ignore errors */
}
--
2.9.2

_______________________________________________
vpnc-devel mailing list
vpnc-devel@unix-ag.uni-kl.de
https://lists.unix-ag.uni-kl.de/mailman/listinfo/vpnc-devel
http://www.unix-ag.uni-kl.de/~massar/vpnc/