summaryrefslogtreecommitdiff
path: root/security/opencryptoki/files/patch-usr-lib-common-utility.c
blob: 106922a9c42d79125ce4db5e703546f664215394 (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
53
54
--- usr/lib/common/utility.c.orig	2018-11-16 14:53:03 UTC
+++ usr/lib/common/utility.c
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <pwd.h>
 #include <grp.h>
+#include <fcntl.h>
 
 #include "pkcs11types.h"
 #include "defs.h"
@@ -35,6 +36,25 @@
 #include <sys/file.h>
 #include <syslog.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
+
 // Function:  dlist_add_as_first()
 //
 // Adds the specified node to the start of the list
@@ -317,7 +337,7 @@ CK_RV CreateXProcLock(char *tokname, STDLL_TokData_t *
                            lockdir, strerror(errno));
                 goto err;
             }
-            grp = getgrnam("pkcs11");
+            grp = getgrnam(PKCS11GROUP);
             if (grp == NULL) {
                 fprintf(stderr, "getgrname(pkcs11): %s", strerror(errno));
                 goto err;
@@ -355,7 +375,7 @@ CK_RV CreateXProcLock(char *tokname, STDLL_TokData_t *
                     goto err;
                 }
 
-                grp = getgrnam("pkcs11");
+                grp = getgrnam(PKCS11GROUP);
                 if (grp != NULL) {
                     if (fchown(tokdata->spinxplfd, -1, grp->gr_gid) == -1) {
                         OCK_SYSLOG(LOG_ERR,