Index: auth.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/auth.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 auth.c
--- auth.c	31 May 2013 07:51:30 -0000	1.1.1.3
+++ auth.c	18 Sep 2014 19:07:59 -0000
@@ -154,25 +154,25 @@ SetAuthentication(int count, IceListenOb
     if ((addAuthFile = unique_filename (path, ".xsm")) == NULL)
 	goto bad;
 
-    if (!(addfp = fopen (addAuthFile, "w")))
+    if (!(addfp = fopen (addAuthFile, "we")))
 	goto bad;
 
     if ((remAuthFile = unique_filename (path, ".xsm")) == NULL)
 	goto bad;
 
-    if (!(removefp = fopen (remAuthFile, "w")))
+    if (!(removefp = fopen (remAuthFile, "we")))
 	goto bad;
 #else
     if ((addAuthFile = unique_filename (path, ".xsm", &fd)) == NULL)
 	goto bad;
     
-    if (!(addfp = fdopen(fd, "wb"))) 
+    if (!(addfp = fdopen(fd, "wbe"))) 
 	goto bad;
 
     if ((remAuthFile = unique_filename (path, ".xsm", &fd)) == NULL)
 	goto bad;
     
-    if (!(removefp = fdopen(fd, "wb"))) 
+    if (!(removefp = fdopen(fd, "wbe"))) 
 	goto bad;
 #endif
 
Index: choose.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/choose.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 choose.c
--- choose.c	31 May 2013 07:51:31 -0000	1.1.1.3
+++ choose.c	18 Sep 2014 19:08:00 -0000
@@ -98,6 +98,8 @@ GetSessionNames(int *count_ret, String *
     if ((dir = opendir (path)) == NULL)
 	return 0;
 
+    (void)fcntl(dirfd(dir), F_SETFD, FD_CLOEXEC);
+
     count = 0;
 
     while ((entry = readdir (dir)) != NULL)
Index: lock.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/lock.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 lock.c
--- lock.c	31 May 2013 07:51:30 -0000	1.1.1.3
+++ lock.c	18 Sep 2014 19:08:00 -0000
@@ -117,7 +117,7 @@ GetLockId(const char *session_name)
     snprintf (lock_file, sizeof(lock_file), "%s/.XSMlock-%s",
 	      path, session_name);
 
-    if ((fp = fopen (lock_file, "r")) == NULL)
+    if ((fp = fopen (lock_file, "re")) == NULL)
     {
 	return (NULL);
     }
Index: remote.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/remote.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 remote.c
--- remote.c	31 May 2013 07:51:30 -0000	1.1.1.3
+++ remote.c	18 Sep 2014 19:08:00 -0000
@@ -111,7 +111,7 @@ remote_start(const char *restart_protoco
 	default:		/* parent */
 
 	    close (pipefd[0]);
-	    fp = (FILE *) fdopen (pipefd[1], "w");
+	    fp = fdopen (pipefd[1], "we");
 
 	    fprintf (fp, "CONTEXT X\n");
 	    fprintf (fp, "DIR %s\n", cwd);
Index: restart.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/restart.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 restart.c
--- restart.c	31 May 2013 07:51:30 -0000	1.1.1.3
+++ restart.c	18 Sep 2014 19:08:00 -0000
@@ -531,11 +531,11 @@ StartDefaultApps (void)
 	home = ".";
     snprintf (filename, sizeof(filename), "%s/.xsmstartup", home);
 
-    f = fopen (filename, "r");
+    f = fopen (filename, "re");
 
     if (!f)
     {
-	f = fopen (SYSTEM_INIT_FILE, "r");
+	f = fopen (SYSTEM_INIT_FILE, "re");
 	if (!f)
 	{
 	    printf ("Could not find default apps file.  Make sure you did\n");
Index: saveutil.c
===================================================================
RCS file: /cvsroot/xsrc/external/mit/xsm/dist/saveutil.c,v
retrieving revision 1.1.1.3
diff -u -p -u -r1.1.1.3 saveutil.c
--- saveutil.c	31 May 2013 07:51:30 -0000	1.1.1.3
+++ saveutil.c	18 Sep 2014 19:08:00 -0000
@@ -65,7 +65,7 @@ ReadSave(const char *session_name, char 
     int			state, i;
     int			version_number;
 
-    f = fopen(session_save_file, "r");
+    f = fopen(session_save_file, "re");
     if(!f) {
 	if (verbose)
 	    printf("No session save file.\n");
@@ -306,7 +306,7 @@ WriteSave(const char *sm_id)
     char *p, *c;
     int count;
 
-    f = fopen (session_save_file, "w");
+    f = fopen (session_save_file, "we");
 
     if (!f)
     {
@@ -427,7 +427,7 @@ DeleteSession(const char *session_name)
 
     snprintf (filename, sizeof(filename), "%s/.XSM-%s", dir, session_name);
 
-    f = fopen(filename, "r");
+    f = fopen(filename, "re");
     if(!f) {
 	return (0);
     }