summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2001-10-24 18:06:22 +0000
committerGeorge Lebl <jirka@src.gnome.org>2001-10-24 18:06:22 +0000
commit04eef84f74899f19fe10aa4d6a19554cfb85b6a3 (patch)
tree202a119e3bc674e3828451b0182acd6f62220afb /utils
parent5bcf6a5d10f8acd0a210f3b2cdceb2fa582e254f (diff)
downloadgdm-04eef84f74899f19fe10aa4d6a19554cfb85b6a3.tar.gz
add a small utility for safely making temp files
Wed Oct 24 11:02:55 2001 George Lebl <jirka@5z.com> * utils/gdmkstemp.c, utils/Makefile.am: add a small utility for safely making temp files Tue Oct 23 15:17:23 2001 George Lebl <jirka@5z.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/.cvsignore1
-rw-r--r--utils/Makefile.am14
-rw-r--r--utils/gdmmkstemp.c32
3 files changed, 44 insertions, 3 deletions
diff --git a/utils/.cvsignore b/utils/.cvsignore
index 005306fe..9e5d14dc 100644
--- a/utils/.cvsignore
+++ b/utils/.cvsignore
@@ -4,3 +4,4 @@ Makefile.in
.deps
gdmaskpass
gdmopen
+gdmmkstemp
diff --git a/utils/Makefile.am b/utils/Makefile.am
index ea97003b..d047fb50 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -20,9 +20,10 @@ INCLUDES = \
$(GNOME_INCLUDEDIR)
sbin_PROGRAMS = \
- @GDMASKPASS@ \
- @GDMOPEN@
-EXTRA_PROGRAMS = gdmaskpass gdmopen
+ @GDMASKPASS@ \
+ @GDMOPEN@ \
+ gdmmkstemp
+EXTRA_PROGRAMS = gdmaskpass gdmopen gdmmkstemp
gdmaskpass_SOURCES = \
gdmaskpass.c
@@ -30,6 +31,9 @@ gdmaskpass_SOURCES = \
gdmopen_SOURCES = \
gdmopen.c
+gdmmkstemp_SOURCES = \
+ gdmmkstemp.c
+
gdmaskpass_LDADD = \
$(GNOME_LIBDIR) \
$(INTLLIBS) \
@@ -39,3 +43,7 @@ gdmaskpass_LDADD = \
gdmopen_LDADD = \
$(GNOME_LIBDIR) \
$(INTLLIBS)
+
+gdmmkstemp_LDADD = \
+ $(GNOME_LIBDIR) \
+ $(INTLLIBS)
diff --git a/utils/gdmmkstemp.c b/utils/gdmmkstemp.c
new file mode 100644
index 00000000..a93c8e01
--- /dev/null
+++ b/utils/gdmmkstemp.c
@@ -0,0 +1,32 @@
+/*
+ * gdmmkstemp.c by the Queen of England
+ * A utility to do mkstemp from a script.
+ *
+ * Copyright (c) 2001 by Queen of England
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char *argv[])
+{
+ char template[] = "/tmp/gdm-XXXXXX";
+ int i;
+
+ i = mkstemp (template);
+ if (i < 0)
+ return 1;
+
+ fchown (i, 0600);
+
+ printf ("%s\n", template);
+ close (i)
+ return 0;
+}