forked from Exhar/otpd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roy van Baekel
committed
Sep 10, 2012
1 parent
5fc2cea
commit 62ded00
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Index: custom/otp/userops/ldap.c | ||
=================================================================== | ||
--- custom.orig/otp/userops/ldap.c 2012-09-10 21:50:15.753943271 +0200 | ||
+++ custom/otp/userops/ldap.c 2012-09-10 21:51:03.634611468 +0200 | ||
@@ -450,9 +450,11 @@ | ||
static void | ||
ldap_put(user_t *user) | ||
{ | ||
- if (user->password) | ||
- free(user->password); | ||
- free(user); | ||
+ if (user) { | ||
+ if (user->password) | ||
+ free(user->password); | ||
+ free(user); | ||
+ } | ||
} | ||
|
||
/* get a bound ldap connection from the pool */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
Index: custom/otp/extern.h | ||
=================================================================== | ||
--- custom.orig/otp/extern.h 2012-09-10 21:36:55.173115123 +0200 | ||
+++ custom/otp/extern.h 2012-09-10 21:44:09.175827798 +0200 | ||
@@ -35,6 +35,9 @@ | ||
/* plugin rendezvous point */ | ||
#define OTPD_PLUGIN_RP "/var/run/otpd/socket" | ||
|
||
+/* pid file */ | ||
+#define OTPD_PIDFILE "/var/run/otpd.pid" | ||
+ | ||
/* statedir */ | ||
#define OTPD_STATEDIR "/etc/otpstate" | ||
|
||
Index: custom/otp/main.c | ||
=================================================================== | ||
--- custom.orig/otp/main.c 2012-09-10 21:36:42.145273195 +0200 | ||
+++ custom/otp/main.c 2012-09-10 21:45:23.339261470 +0200 | ||
@@ -47,6 +47,7 @@ | ||
pthread_attr_t attr_detached; /* create all threads detached */ | ||
|
||
char *opt_c; /* config file */ | ||
+char *opt_pid; /* PID file */ | ||
char *opt_u; /* user */ | ||
char *opt_p; /* plugin rp */ | ||
char *opt_d; /* log_level */ | ||
@@ -86,6 +87,7 @@ | ||
{ | ||
pid_t pid; | ||
int fd0, fd1, fd2; | ||
+ FILE *pidfd; | ||
int i; | ||
#ifndef HAVE_CLOSEFROM | ||
struct rlimit rl; | ||
@@ -151,6 +153,17 @@ | ||
exit(1); | ||
} | ||
|
||
+ /* record our pid */ | ||
+ if (!opt_pid) | ||
+ opt_pid = OTPD_PIDFILE; | ||
+ if ((pidfd = fopen(opt_pid,"w")) != (FILE *) NULL) { | ||
+ fprintf(pidfd, "%d\n", getpid()); | ||
+ fclose(pidfd); | ||
+ } else { | ||
+ mlog(LOG_CRIT, "%s: could not write PID file %s" , __func__, opt_pid); | ||
+ exit(1); | ||
+ } | ||
+ | ||
/* initialize syslog */ | ||
mopenlog(basename(progname), LOG_PID|LOG_NDELAY); | ||
} | ||
@@ -166,6 +179,7 @@ | ||
" -c <file> use config file <file>\n" | ||
" -u <user> run as user <user> \n" | ||
" -p <rp> listen to plugins at rendezvous point <rp> \n" | ||
+" -P <pidfile> (daemon only) write out our PID to file <pidfile>\n" | ||
" -f run in foreground\n" | ||
" -d <level> set debug level <level>\n" | ||
" -D set max debug level\n", | ||
@@ -187,12 +201,14 @@ | ||
{ | ||
int c; | ||
|
||
- while ((c = getopt(argc, argv, ":hvc:d:fDu:p:")) != -1) { | ||
+ while ((c = getopt(argc, argv, ":hvc:P:d:fDu:p:")) != -1) { | ||
switch (c) { | ||
case 'c': /* config file */ | ||
opt_c = optarg; | ||
break; | ||
- | ||
+ case 'P': /* PID file */ | ||
+ opt_pid = optarg; | ||
+ break; | ||
case 'd': /* debug */ | ||
opt_d = optarg; | ||
break; | ||
@@ -270,6 +286,10 @@ | ||
(void) sigemptyset(&set); | ||
(void) pthread_sigmask(SIG_SETMASK, &set, NULL); | ||
|
||
+ /* unlink our PID file */ | ||
+ unlink(OTPD_PIDFILE); | ||
+ | ||
+ /* wait for all threads to shut down */ | ||
for (;;) | ||
(void) pause(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ldap_user_not_found | ||
strncmp_error | ||
pid-file-support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Index: custom/otp/userops/ldap.c | ||
=================================================================== | ||
--- custom.orig/otp/userops/ldap.c 2012-09-10 21:48:36.178656544 +0200 | ||
+++ custom/otp/userops/ldap.c 2012-09-10 21:48:59.794200507 +0200 | ||
@@ -321,7 +321,7 @@ | ||
} | ||
|
||
if (p[0] == '{') { | ||
- if (strncmp(p, "{MD5}", 5)) { | ||
+ if (strncmp(p, "{MD5}", 5)==0) { | ||
p += 5; | ||
if (strlen(p) != 32 || a2nx(p, h, 16) != 16) { | ||
mlog(LOG_ERR, "%s: otpTmpStaticPassword for [%s] invalid", |