blob: 0d2d3f45b862526b689c05d626ca0967fdbad62e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
--- a/plugins/scripting/cunixsocket.cpp
+++ b/plugins/scripting/cunixsocket.cpp
@@ -40,12 +40,21 @@
varlist = 0;
connected = false;
- //first of all, we need a file name
- char *fname = tempnam ("/tmp", "km");
- if (fname != 0) //only if it didn't fail
+ //22 = strlen(form) + strlen(/sock) + 1
+ char form[]="/tmp/kmuddyXXXXXX", *dirname, sockname[22];
+ dirname = mkdtemp(form);
+
+ if (dirname != NULL) //only if it didn't fail
{
- name = fname;
- free (fname);
+
+ strcpy(sockname, dirname);
+ strcat(dirname, "/sock");
+
+ name = dirname;
+ free (form);
+ free (dirname);
+ free (sockname);
+
//now that we have the name, we create a socket and set some parameters
id = socket (PF_UNIX, SOCK_STREAM, 0);
sa.sun_family = AF_UNIX;
|