[Pcsclite-cvs-commit] r2551 - trunk/PCSC/src

rousseau at alioth.debian.org rousseau at alioth.debian.org
Tue May 29 13:19:11 UTC 2007


Author: rousseau
Date: 2007-05-29 13:19:11 +0000 (Tue, 29 May 2007)
New Revision: 2551

Modified:
   trunk/PCSC/src/pcscdaemon.c
Log:
set the permission on USE_RUN_PID so that the file is world readable.
The file is used by libpcsclite to check the availability of pcscd


Modified: trunk/PCSC/src/pcscdaemon.c
===================================================================
--- trunk/PCSC/src/pcscdaemon.c	2007-05-29 13:18:09 UTC (rev 2550)
+++ trunk/PCSC/src/pcscdaemon.c	2007-05-29 13:19:11 UTC (rev 2551)
@@ -24,6 +24,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -425,13 +426,23 @@
 	 * to kill the correct pcscd
 	 */
 	{
-		FILE *f;
+		int f;
 
-		if ((f = fopen(USE_RUN_PID, "wb")) != NULL)
+		if ((f = SYS_OpenFile(USE_RUN_PID, O_RDWR | O_CREAT, 00644)) != -1)
 		{
-			fprintf(f, "%u\n", (unsigned) getpid());
-			fclose(f);
+			char pid[PID_ASCII_SIZE];
+
+			snprintf(pid, sizeof(pid), "%u", (unsigned) getpid());
+			SYS_WriteFile(f, pid, strlen(pid));
+			SYS_CloseFile(f);
+
+			/* set mode so that the file is world readable.
+			 * The file is used by libpcsclite */
+			SYS_Chmod(USE_RUN_PID, 0644);
 		}
+		else
+			Log2(PCSC_LOG_CRITICAL, "cannot create " USE_RUN_PID ": %s",
+				strerror(errno));
 	}
 
 	/*




More information about the Pcsclite-cvs-commit mailing list