ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/mail/courier/files/patch-liblock__locktest.c
Revision: 16349
Committed: Sun Apr 20 18:32:36 2014 UTC (9 years, 11 months ago) by laffer1
Content type: text/plain
File size: 1400 byte(s)
Log Message:
remove cvs2svn:cvs-rev prop

File Contents

# Content
1 --- liblock/locktest.c.orig Mon Dec 6 08:18:55 1999
2 +++ liblock/locktest.c Mon Dec 6 08:18:55 1999
3 @@ -5,6 +5,7 @@
4
5 /* $Id */
6
7 +#include <paths.h>
8 #include "liblock.h"
9 #if USE_FCNTL
10 #include "lockfcntl.c"
11 @@ -20,11 +21,23 @@
12
13 int main()
14 {
15 +#define FILENAME "courier-authlib.locktest.XXXXX"
16 int fd[2];
17 pid_t p;
18 int s;
19 int f;
20
21 + char *name;
22 + const char *tmpdir;
23 + if ((tmpdir = (char *)getenv("TMPDIR")) == NULL)
24 + tmpdir = _PATH_TMP;
25 + (void)asprintf(&name, "%s%s%s", tmpdir,
26 + (tmpdir[strlen(tmpdir) - 1] == '/') ? "" : "/", FILENAME);
27 + if (name == NULL) {
28 + perror("get filename");
29 + exit(1);
30 + }
31 +
32 signal(SIGCHLD, SIG_DFL);
33 if (pipe(fd))
34 {
35 @@ -32,6 +45,12 @@
36 return (1);
37 }
38
39 + if ((f=mkstemp(name)) < 0)
40 + {
41 + perror("open");
42 + exit(1);
43 + }
44 +
45 if ((p=fork()) == (pid_t)-1)
46 {
47 perror("fork");
48 @@ -46,7 +65,7 @@
49 read(fd[0], &c, 1);
50 close(fd[0]);
51
52 - if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
53 + if ((f=open(name, O_RDWR)) < 0)
54 {
55 perror("open");
56 exit(1);
57 @@ -56,22 +75,18 @@
58 if (ll_lockfd(f, ll_writelock, 0, 0))
59 {
60 close(f);
61 + unlink(name);
62 exit(0);
63 }
64 close(f);
65 exit(1);
66 }
67 -
68 - if ((f=open("conftest.lock", O_RDWR|O_CREAT, 0644)) < 0)
69 - {
70 - perror("open");
71 - exit(1);
72 - }
73
74 if (ll_lockfd(f, ll_writelock, 0, 0))
75 {
76 perror("lock");
77 close(f);
78 + unlink(name);
79 exit(1);
80 }
81 close(fd[1]);