openbsd-ports/x11/kde/libs2/patches/patch-kdesu_stub_c

76 lines
2.0 KiB
Plaintext

$OpenBSD: patch-kdesu_stub_c,v 1.3 2001/03/14 00:17:32 espie Exp $
--- kdesu/kdesu_stub.c.orig Sat Mar 10 15:22:48 2001
+++ kdesu/kdesu_stub.c Sat Mar 10 15:48:03 2001
@@ -276,9 +276,11 @@ int main()
xsetenv("DISPLAY", params[P_DISPLAY].value);
if (params[P_DISPLAY_AUTH].value[0])
{
- fname = tmpnam(0L);
- fout = fopen(fname, "w");
- if (!fout)
+ int fd;
+ strcpy(fname, "/tmp/kdesu.XXXXXXXXXX");
+
+ fd = mkstemp(fname);
+ if (fd == -1 || (fout = fdopen(fd, "w")) == NULL)
{
perror("kdesu_stub: fopen()");
exit(1);
@@ -286,7 +288,19 @@ int main()
fprintf(fout, "add %s %s\n", params[P_DISPLAY].value,
params[P_DISPLAY_AUTH].value);
fclose(fout);
- tmpnam(xauthority);
+ strcpy(xauthority, "/tmp/xauth.XXXXXXXXXX");
+ {
+ int fd;
+
+ fd = mkstemp(xauthority);
+ if (fd == -1)
+ {
+ perror("kdesu_stub: mkstemp()");
+ exit(1);
+ }
+ else
+ close(fd);
+ }
xsetenv("XAUTHORITY", xauthority);
sprintf(command, "xauth source %s >/dev/null 2>&1", fname);
if (system(command))
@@ -305,9 +319,11 @@ int main()
auth = xstrsep(params[P_ICE_AUTH].value);
if (host[0])
{
- fname = tmpnam(0L);
- fout = fopen(fname, "w");
- if (!fout)
+ int fd;
+ strcpy(fname, "/tmp/kdesu.XXXXXXXXXX");
+
+ fd = mkstemp(fname);
+ if (fd == -1 || (fout = fdopen(fd, "w")) == NULL)
{
perror("kdesu_stub: fopen()");
exit(1);
@@ -318,7 +334,19 @@ int main()
for (i=0; host[i]; i++)
fprintf(fout, "add DCOP \"\" %s %s\n", host[i], auth[i]);
fclose(fout);
- tmpnam(iceauthority);
+ strcpy(iceauthority, "/tmp/iceauth.XXXXXXXXXX");
+ {
+ int fd;
+
+ fd = mkstemp(iceauthority);
+ if (fd == -1)
+ {
+ perror("kdesu_stub: mkstemp()");
+ exit(1);
+ }
+ else
+ close(fd);
+ }
xsetenv("ICEAUTHORITY", iceauthority);
sprintf(command, "iceauth source %s >/dev/null 2>&1", fname);
if (system(command))