summaryrefslogtreecommitdiff
path: root/security/opencryptoki/files/patch-usr-sbin-pkcsslotd-mutex.c
blob: 412566aa9422459be3e90a180b1f62898202fa86 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- usr/sbin/pkcsslotd/mutex.c.orig	2010-07-29 21:28:41.000000000 +0900
+++ usr/sbin/pkcsslotd/mutex.c	2010-12-19 12:13:34.837579374 +0900
@@ -293,6 +293,26 @@
 
 #include "pkcsslotd.h"
 
+#include <fcntl.h>
+
+#ifdef __sun
+#define	LOCK_EX	F_LOCK
+#define	LOCK_UN	F_ULOCK
+#define	flock(fd, func)	lockf(fd, func, 0)
+#endif
+
+#ifndef	LOCK_SH
+#define	LOCK_SH	1	/* shared lock */
+#endif
+#ifndef	LOCK_EX
+#define	LOCK_EX	2	/* exclusive lock */
+#endif
+#ifndef	LOCK_NB
+#define	LOCK_NB	4	/* don't block when locking */
+#endif
+#ifndef	LOCK_UN
+#define	LOCK_UN	8	/* unlock */
+#endif
 
 #if SYSVSEM
 #error "Caveat Emptor... this does not work"
@@ -315,7 +335,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <sys/file.h>
+#include <grp.h>
 static int xplfd=-1;
 #endif
 
@@ -349,6 +369,13 @@
 #elif (SPINXPL)
   
  xplfd = open (XPL_FILE,O_CREAT|O_RDWR,S_IRWXU|S_IRWXG|S_IRWXO);
+ {
+	struct group *grp;
+	fchmod(xplfd,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+	grp = getgrnam(PKCS11GROUP);
+	if (grp)
+		fchown(xplfd,getuid(),grp->gr_gid);
+ }
 
 #elif (SYSVSEM)
 #error "Caveat Emptor... this does not work"