if (volume->v_flags & AFPVOL_TM) {
char *uuid = get_uuid(obj, volume->v_localname);
if (!uuid) {
- LOG(log_error, logtype_afpd, "Volume '%s': couldn't get UUID, disabling TM support",
+ LOG(log_error, logtype_afpd, "Volume '%s': couldn't get UUID",
volume->v_localname);
- volume->v_flags &= ~AFPVOL_TM;
} else {
volume->v_uuid = uuid;
LOG(log_debug, logtype_afpd, "Volume '%s': UUID '%s'",
*/
char *get_uuid(const AFPObj *obj, const char *volname)
{
- struct stat st;
-
- char *usersign;
- int fd, i;
- struct stat tmpstat;
char *volname_conf;
- int header = 0;
char buf[1024], uuid[UUID_PRINTABLE_STRING_LENGTH], *p;
- FILE *fp, *randomp;
- size_t len;
+ FILE *fp;
+ struct stat tmpstat;
+ int fd;
if ((fp = fopen(obj->options.uuidconf, "r")) != NULL) { /* read open? */
/* scan in the conf file */
p++;
if (sscanf(p, "%36s", uuid) == 1 ) {
+ for (int i=0; uuid[i]; i++)
+ uuid[i] = toupper(uuid[i]);
LOG(log_debug, logtype_afpd, "get_uuid('%s'): UUID: '%s'", volname, uuid);
fclose(fp);
return strdup(uuid);
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;
uuid_t id;
uuid_generate(id);
uuid_unparse(id, uuid);
+ for (int i=0; uuid[i]; i++)
+ uuid[i] = toupper(uuid[i]);
LOG(log_debug, logtype_afpd, "get_uuid('%s'): generated UUID '%s'", volname, uuid);
fprintf(fp, "\"%s\"\t%36s\n", volname, uuid);