Line 0
Link Here
|
|
|
1 |
=================================================================== |
2 |
RCS file: /cvsroot/cscope/cscope/src/main.c,v |
3 |
retrieving revision 1.33 |
4 |
retrieving revision 1.34 |
5 |
diff -u -r1.33 -r1.34 |
6 |
--- src/main.c 2004/04/30 15:31:43 1.33 |
7 |
+++ src/main.c 2004/12/06 14:56:43 1.34 |
8 |
@@ -101,6 +101,7 @@ |
9 |
#endif |
10 |
char temp1[PATHLEN + 1]; /* temporary file name */ |
11 |
char temp2[PATHLEN + 1]; /* temporary file name */ |
12 |
+char tempdirpv[PATHLEN +1]; /* private temp directory */ |
13 |
long totalterms; /* total inverted index terms */ |
14 |
BOOL trun_syms; /* truncate symbols to 8 characters */ |
15 |
char tempstring[8192]; /* use this as a buffer, instead of 'yytext', |
16 |
@@ -131,6 +132,7 @@ |
17 |
int c, i; |
18 |
pid_t pid; |
19 |
struct stat stat_buf; |
20 |
+ mode_t orig_umask; |
21 |
|
22 |
yyin = stdin; |
23 |
yyout = stdout; |
24 |
@@ -330,9 +332,18 @@ |
25 |
} |
26 |
|
27 |
/* create the temporary file names */ |
28 |
+ orig_umask = umask(S_IRWXG|S_IRWXO); |
29 |
pid = getpid(); |
30 |
- (void) sprintf(temp1, "%s/cscope%d.1", tmpdir, pid); |
31 |
- (void) sprintf(temp2, "%s/cscope%d.2", tmpdir, pid); |
32 |
+ (void) sprintf(tempdirpv, "%s/cscope.%d", tmpdir, pid); |
33 |
+ if(mkdir(tempdirpv,S_IRWXU)) |
34 |
+ { |
35 |
+ fprintf(stderr, "cscope: Could not create private temp dir %s\n",tempdirpv); |
36 |
+ myexit(1); |
37 |
+ } |
38 |
+ umask(orig_umask); |
39 |
+ |
40 |
+ (void) sprintf(temp1, "%s/cscope.1", tempdirpv, pid); |
41 |
+ (void) sprintf(temp2, "%s/cscope.2", tempdirpv, pid); |
42 |
|
43 |
/* if running in the foreground */ |
44 |
if (signal(SIGINT, SIG_IGN) != SIG_IGN) { |
45 |
@@ -834,6 +845,7 @@ |
46 |
if (temp1[0] != '\0') { |
47 |
(void) unlink(temp1); |
48 |
(void) unlink(temp2); |
49 |
+ (void) rmdir(tempdirpv); |
50 |
} |
51 |
/* restore the terminal to its original mode */ |
52 |
if (incurses == YES) { |