diff options
author | rrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2007-08-14 23:04:08 +0000 |
---|---|---|
committer | rrelyea <rrelyea@fba4d07e-fe0f-4d7f-8147-e0026e666dc0> | 2007-08-14 23:04:08 +0000 |
commit | 618345fa24565afa27e580f932641ea6edbb197e (patch) | |
tree | d24ea4b30d5e73943f7b717252e804067fb9f21f /src | |
parent | 4beff1ea687a5c8f0c141e9e85da28d6f3c01884 (diff) |
Move the cache to /var/cache where the coolkey package can own and control
the directory better.
git-svn-id: http://svn.fedorahosted.org/svn/coolkey/trunk@67 fba4d07e-fe0f-4d7f-8147-e0026e666dc0
Diffstat (limited to 'src')
-rw-r--r-- | src/coolkey/machdep.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/coolkey/machdep.cpp b/src/coolkey/machdep.cpp index 180f6f4..d7ce38e 100644 --- a/src/coolkey/machdep.cpp +++ b/src/coolkey/machdep.cpp @@ -185,12 +185,20 @@ void OSSleep(int time) #define MAP_INHERIT 0 #endif +#ifndef BASEPATH +#ifdef MAC +#define BASEPATH "/var" +#else +#define BASEPATH "/var/cache" +#endif +#endif + #ifdef FULL_CLEANUP #define RESERVED_OFFSET 256 -#define MEMSEGPATH "/tmp/.pk11ipc" +#define MEMSEGPATH BASEPATH"/pk11ipc" #else #define RESERVED_OFFSET 0 -#define MEMSEGPATH "/tmp/.pk11ipc1" +#define MEMSEGPATH BASEPATH"/pk11ipc1" #endif struct SHMemData { @@ -208,11 +216,6 @@ SHMemData::~SHMemData() { #ifdef FULL_CLEANUP flock(fd,LOCK_EX); unsigned long ref = --(*(unsigned long *)addr); -#ifdef notdef - if (ref == 0) { - unlink(path); - } -#endif flock(fd, LOCK_UN); #endif munmap(addr,size+RESERVED_OFFSET); @@ -248,7 +251,7 @@ SHMem::initSegment(const char *name, int size, bool &init) return NULL; } int mask = umask(0); - int ret = mkdir (MEMSEGPATH, 0777); + int ret = mkdir (MEMSEGPATH, 1777); umask(mask); if ((ret == -1) && (errno != EEXIST)) { delete shmemData; @@ -264,18 +267,15 @@ SHMem::initSegment(const char *name, int size, bool &init) shmemData->path[sizeof(MEMSEGPATH)-1] = '/'; strcpy(&shmemData->path[sizeof(MEMSEGPATH)],name); - int mode = 0777; - if (strcmp(name,"token_names") != 0) { - /* each user gets his own uid array */ - sprintf(uid_str, "-%u",getuid()); - strcat(shmemData->path,uid_str); - mode = 0700; - } + sprintf(uid_str, "-%u",getuid()); + strcat(shmemData->path,uid_str); + int mode = 0600; + shmemData->fd = open(shmemData->path, O_CREAT|O_RDWR|O_EXCL|O_APPEND|O_EXLOCK, mode); - if (shmemData->fd < 0) { + if ((shmemData->fd < 0) && errno == EEXIST) { needInit = false; - shmemData->fd = open(shmemData->path,O_RDWR|O_EXLOCK, mode); + shmemData->fd = open(shmemData->path,O_RDWR|O_EXLOCK|O_NOFOLLOW, mode); } else { char *buf; int len = size+RESERVED_OFFSET; |