mkdir() instead of system()
authorVolker Birk <vb@pep-project.org>
Sat, 28 Mar 2015 11:09:57 +0100
changeset 1499eadaa00cc8d
parent 148 817eae99bca2
child 150 a8672133ab9d
mkdir() instead of system()
src/Makefile
src/platform_unix.c
     1.1 --- a/src/Makefile	Sat Mar 28 10:53:27 2015 +0100
     1.2 +++ b/src/Makefile	Sat Mar 28 11:09:57 2015 +0100
     1.3 @@ -12,7 +12,7 @@
     1.4  CFLAGS?=-I$(GPGME_IN)/include -I$(HOME)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
     1.5  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"
     1.6  LDFLAGS?=-lc -shared -arch x86_64 \
     1.7 -	-L$(HOME)/lib -L/opt/local/lib -letpan -lgpgme-pthread -lsqlite
     1.8 +	-L$(HOME)/lib -L/opt/local/lib -letpan -lgpgme-pthread -lsqlite3
     1.9  
    1.10  else
    1.11  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
     2.1 --- a/src/platform_unix.c	Sat Mar 28 10:53:27 2015 +0100
     2.2 +++ b/src/platform_unix.c	Sat Mar 28 11:09:57 2015 +0100
     2.3 @@ -3,6 +3,8 @@
     2.4  #include <string.h>
     2.5  #include <stdlib.h>
     2.6  #include <assert.h>
     2.7 +#include <sys/types.h>
     2.8 +#include <sys/stat.h>
     2.9  #include "platform_unix.h"
    2.10  
    2.11  #define MAX_PATH 1024
    2.12 @@ -55,17 +57,17 @@
    2.13  
    2.14          *p++ = '/';
    2.15          strncpy(p, gpg_conf_path, len);
    2.16 +
    2.17 +        mkdir(p, 0700);
    2.18 +        // we ignore the return value intentionally
    2.19 +
    2.20          p += strlen(gpg_conf_path);
    2.21          len -= strlen(gpg_conf_path) - 1;
    2.22          *p++ = '/';
    2.23          strncpy(p, gpg_conf_name, len);
    2.24  
    2.25 -        // GPG creates conf dir if missing.
    2.26 -        // --gen-random of one byte is most
    2.27 -        // non-intrusive command
    2.28 -        system("gpg --gen-random 0 1");
    2.29 -
    2.30          done = true;
    2.31      }
    2.32 +
    2.33      return buffer;
    2.34  }