]> arthur.barton.de Git - netatalk.git/commitdiff
afp_voluuid.conf mode 644
authorHAT <hat@fa2.so-net.ne.jp>
Sat, 26 Jun 2010 16:38:37 +0000 (01:38 +0900)
committerHAT <hat@fa2.so-net.ne.jp>
Sat, 26 Jun 2010 16:38:37 +0000 (01:38 +0900)
etc/afpd/volume.c

index 652483110677212ef264d459ece613ad83704c6b..88b55ce1e37e8e357c6866234bcdaf4748dc2a9f 100644 (file)
@@ -2651,6 +2651,8 @@ char *get_uuid(const AFPObj *obj, const char *volname)
     char *volname_conf;
     char buf[1024], uuid[UUID_PRINTABLE_STRING_LENGTH], *p;
     FILE *fp;
+    struct stat tmpstat;
+    int fd;
     
     if ((fp = fopen(obj->options.uuidconf, "r")) != NULL) {  /* read open? */
         /* scan in the conf file */
@@ -2693,7 +2695,20 @@ char *get_uuid(const AFPObj *obj, const char *volname)
         fclose(fp);
 
     /*  not found or no file, reopen in append mode */
-    if ((fp = fopen(obj->options.uuidconf, "a+")) == NULL) {
+
+    if (stat(obj->options.uuidconf, &tmpstat)) {                /* no file */
+        if (( fd = creat(obj->options.uuidconf, 0644 )) < 0 ) {
+            LOG(log_error, logtype_atalkd, "ERROR: Cannot create %s (%s).",
+                obj->options.uuidconf, strerror(errno));
+            return NULL;
+        }
+        if (( fp = fdopen( fd, "w" )) == NULL ) {
+            LOG(log_error, logtype_atalkd, "ERROR: Cannot fdopen %s (%s).",
+                obj->options.uuidconf, strerror(errno));
+            close(fd);
+            return NULL;
+        }
+    } else if ((fp = fopen(obj->options.uuidconf, "a+")) == NULL) { /* not found */
         LOG(log_error, logtype_afpd, "Cannot create or append to %s (%s).",
             obj->options.uuidconf, strerror(errno));
         return NULL;