[Pcsclite-cvs-commit] r3082 - in /trunk/PCSC/src: eventhandler.c pcscdaemon.c

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Thu Aug 7 07:12:35 UTC 2008


Author: rousseau
Date: Thu Aug  7 07:12:34 2008
New Revision: 3082

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=3082
Log:
call SYS_Chmod() for PCSCLITE_RUN_PID and PCSCLITE_PUBSHM_FILE to force
the file access mode in case umask is too restrictive

Modified:
    trunk/PCSC/src/eventhandler.c
    trunk/PCSC/src/pcscdaemon.c

Modified: trunk/PCSC/src/eventhandler.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/eventhandler.c?rev=3082&op=diff
==============================================================================
--- trunk/PCSC/src/eventhandler.c (original)
+++ trunk/PCSC/src/eventhandler.c Thu Aug  7 07:12:34 2008
@@ -43,6 +43,7 @@
 LONG EHInitializeEventStructures(void)
 {
 	int fd, i, pageSize;
+	int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 
 	fd = 0;
 	i = 0;
@@ -50,8 +51,7 @@
 
 	SYS_RemoveFile(PCSCLITE_PUBSHM_FILE);
 
-	fd = SYS_OpenFile(PCSCLITE_PUBSHM_FILE, O_RDWR | O_CREAT,
-		S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+	fd = SYS_OpenFile(PCSCLITE_PUBSHM_FILE, O_RDWR | O_CREAT, mode);
 	if (fd < 0)
 	{
 		Log3(PCSC_LOG_CRITICAL, "Cannot create public shared file %s: %s",
@@ -60,6 +60,9 @@
 	}
 
 	pageSize = SYS_GetPageSize();
+
+	/* set correct mode even is umask is too restictive */
+	SYS_Chmod(PCSCLITE_PUBSHM_FILE, mode);
 
 	/*
 	 * Jump to end of file space and allocate zero's

Modified: trunk/PCSC/src/pcscdaemon.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/pcscdaemon.c?rev=3082&op=diff
==============================================================================
--- trunk/PCSC/src/pcscdaemon.c (original)
+++ trunk/PCSC/src/pcscdaemon.c Thu Aug  7 07:12:34 2008
@@ -425,17 +425,20 @@
 	 */
 	{
 		int f;
-
-		/* set mode so that the file is world readable.
-		 * The file is used by libpcsclite */
-		if ((f = SYS_OpenFile(PCSCLITE_RUN_PID, O_RDWR | O_CREAT,
-			S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) != -1)
+		int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
+
+		if ((f = SYS_OpenFile(PCSCLITE_RUN_PID, O_RDWR | O_CREAT, mode)) != -1)
 		{
 			char pid[PID_ASCII_SIZE];
 
 			snprintf(pid, sizeof(pid), "%u\n", (unsigned) getpid());
 			SYS_WriteFile(f, pid, strlen(pid));
 			SYS_CloseFile(f);
+
+			/* set mode so that the file is world readable even is umask is
+			 * restrictive
+			 * The file is used by libpcsclite */
+			SYS_Chmod(PCSCLITE_RUN_PID, mode);
 		}
 		else
 			Log2(PCSC_LOG_CRITICAL, "cannot create " PCSCLITE_RUN_PID ": %s",




More information about the Pcsclite-cvs-commit mailing list