835a514394
now also use courier-authlib (which is new) as the authentication stuff has been moved there. This should make our courier system again faily complete, we have been running this code for almost a year.
83 lines
1.5 KiB
Plaintext
83 lines
1.5 KiB
Plaintext
$OpenBSD: patch-liblock_locktest_c,v 1.1 2006/11/03 16:19:56 mbalmer Exp $
|
|
--- liblock/locktest.c.orig Mon Dec 6 11:18:55 1999
|
|
+++ liblock/locktest.c Fri Jan 6 19:06:31 2006
|
|
@@ -5,6 +5,7 @@
|
|
|
|
/* $Id */
|
|
|
|
+#include <paths.h>
|
|
#include "liblock.h"
|
|
#if USE_FCNTL
|
|
#include "lockfcntl.c"
|
|
@@ -20,11 +21,23 @@
|
|
|
|
int main()
|
|
{
|
|
+#define FILENAME "courier-authlib.locktest.XXXXX"
|
|
int fd[2];
|
|
pid_t p;
|
|
int s;
|
|
int f;
|
|
|
|
+ char *name;
|
|
+ const char *tmpdir;
|
|
+ if ((tmpdir = (char *)getenv("TMPDIR")) == NULL)
|
|
+ tmpdir = _PATH_TMP;
|
|
+ (void)asprintf(&name, "%s%s%s", tmpdir,
|
|
+ (tmpdir[strlen(tmpdir) - 1] == '/') ? "" : "/", FILENAME);
|
|
+ if (name == NULL) {
|
|
+ perror("get filename");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
signal(SIGCHLD, SIG_DFL);
|
|
if (pipe(fd))
|
|
{
|
|
@@ -32,6 +45,12 @@ int f;
|
|
return (1);
|
|
}
|
|
|
|
+ if ((f=mkstemp(name)) < 0)
|
|
+ {
|
|
+ perror("open");
|
|
+ exit(1);
|
|
+ }
|
|
+
|
|
if ((p=fork()) == (pid_t)-1)
|
|
{
|
|
perror("fork");
|
|
@@ -46,7 +65,7 @@ int f;
|
|
read(fd[0], &c, 1);
|
|
close(fd[0]);
|
|
|
|
- if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
|
|
+ if ((f=open(name, O_RDWR)) < 0)
|
|
{
|
|
perror("open");
|
|
exit(1);
|
|
@@ -56,22 +75,18 @@ int f;
|
|
if (ll_lockfd(f, ll_writelock, 0, 0))
|
|
{
|
|
close(f);
|
|
+ unlink(name);
|
|
exit(0);
|
|
}
|
|
close(f);
|
|
exit(1);
|
|
}
|
|
-
|
|
- if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
|
|
- {
|
|
- perror("open");
|
|
- exit(1);
|
|
- }
|
|
|
|
if (ll_lockfd(f, ll_writelock, 0, 0))
|
|
{
|
|
perror("lock");
|
|
close(f);
|
|
+ unlink(name);
|
|
exit(1);
|
|
}
|
|
close(fd[1]);
|