X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libatalk%2Fvfs%2Fea_ad.c;h=5b99a5c321b2052866307aa161615188ca61b59d;hb=76b379ad71f4b129fade5611356b103b7ca6d39a;hp=016f92fb7878dbc065a09d76f10cff0632af86fa;hpb=802908edf9df6d57637c0b3d410f0c0b4c3509c6;p=netatalk.git diff --git a/libatalk/vfs/ea_ad.c b/libatalk/vfs/ea_ad.c index 016f92fb..5b99a5c3 100644 --- a/libatalk/vfs/ea_ad.c +++ b/libatalk/vfs/ea_ad.c @@ -79,7 +79,7 @@ static char *mtoupath(const struct vol *vol, const char *mpath) char *u; size_t inplen; size_t outlen; - uint16_t flags = CONV_ESCAPEHEX | CONV_ALLOW_COLON; + uint16_t flags = CONV_ESCAPEHEX; if (!mpath) return NULL; @@ -906,7 +906,7 @@ int ea_close(struct ea * restrict ea) if (ea->ea_count == 0) { /* Check if EA header exists and remove it */ eaname = ea_path(ea, NULL, 0); - if ((lstatat(ea->dirfd, eaname, &st)) == 0) { + if ((statat(ea->dirfd, eaname, &st)) == 0) { if ((netatalk_unlinkat(ea->dirfd, eaname)) != 0) { LOG(log_error, logtype_afpd, "ea_close('%s'): unlink: %s", eaname, strerror(errno)); @@ -1065,7 +1065,7 @@ int get_easize(VFS_FUNC_ARGS_EA_GETSIZE) */ int get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT) { - int ret = AFPERR_MISC, fd = -1; + int ret = AFPERR_MISC; unsigned int count = 0; uint32_t uint32; size_t toread; @@ -1583,7 +1583,7 @@ int ea_chown(VFS_FUNC_ARGS_CHOWN) } } - if ((lchown(ea_path(&ea, NULL, 0), uid, gid)) != 0) { + if ((ochown(ea_path(&ea, NULL, 0), uid, gid, vol_syml_opt(vol))) != 0) { switch (errno) { case EPERM: case EACCES: @@ -1600,7 +1600,7 @@ int ea_chown(VFS_FUNC_ARGS_CHOWN) ret = AFPERR_MISC; goto exit; } - if ((lchown(eaname, uid, gid)) != 0) { + if ((ochown(eaname, uid, gid, vol_syml_opt(vol))) != 0) { switch (errno) { case EPERM: case EACCES: @@ -1644,7 +1644,7 @@ int ea_chmod_file(VFS_FUNC_ARGS_SETFILEMODE) } /* Set mode on EA header file */ - if ((setfilmode(ea_path(&ea, NULL, 0), ea_header_mode(mode), NULL, vol->v_umask)) != 0) { + if ((setfilmode(vol, ea_path(&ea, NULL, 0), ea_header_mode(mode), NULL)) != 0) { LOG(log_error, logtype_afpd, "ea_chmod_file('%s'): %s", ea_path(&ea, NULL, 0), strerror(errno)); switch (errno) { case EPERM: @@ -1663,7 +1663,7 @@ int ea_chmod_file(VFS_FUNC_ARGS_SETFILEMODE) ret = AFPERR_MISC; goto exit; } - if ((setfilmode(eaname, ea_mode(mode), NULL, vol->v_umask)) != 0) { + if ((setfilmode(vol, eaname, ea_mode(mode), NULL)) != 0) { LOG(log_error, logtype_afpd, "ea_chmod_file('%s'): %s", eaname, strerror(errno)); switch (errno) { case EPERM: @@ -1694,33 +1694,25 @@ int ea_chmod_dir(VFS_FUNC_ARGS_SETDIRUNIXMODE) int ret = AFP_OK; unsigned int count = 0; - uid_t uid; const char *eaname; const char *eaname_safe = NULL; struct ea ea; LOG(log_debug, logtype_afpd, "ea_chmod_dir('%s')", name); /* .AppleDouble already might be inaccesible, so we must run as id 0 */ - uid = geteuid(); - if (seteuid(0)) { - LOG(log_error, logtype_afpd, "ea_chmod_dir('%s'): seteuid: %s", name, strerror(errno)); - return AFPERR_MISC; - } + become_root(); /* Open EA stuff */ if ((ea_open(vol, name, EA_RDWR, &ea)) != 0) { /* ENOENT --> no EA files, nothing to do */ if (errno != ENOENT) ret = AFPERR_MISC; - if (seteuid(uid) < 0) { - LOG(log_error, logtype_afpd, "can't seteuid back: %s", strerror(errno)); - exit(EXITERR_SYS); - } + unbecome_root(); return ret; } /* Set mode on EA header */ - if ((setfilmode(ea_path(&ea, NULL, 0), ea_header_mode(mode), NULL, vol->v_umask)) != 0) { + if ((setfilmode(vol, ea_path(&ea, NULL, 0), ea_header_mode(mode), NULL)) != 0) { LOG(log_error, logtype_afpd, "ea_chmod_dir('%s'): %s", ea_path(&ea, NULL, 0), strerror(errno)); switch (errno) { case EPERM: @@ -1750,7 +1742,7 @@ int ea_chmod_dir(VFS_FUNC_ARGS_SETDIRUNIXMODE) ret = AFPERR_MISC; goto exit; } - if ((setfilmode(eaname, ea_mode(mode), NULL, vol->v_umask)) != 0) { + if ((setfilmode(vol, eaname, ea_mode(mode), NULL)) != 0) { LOG(log_error, logtype_afpd, "ea_chmod_dir('%s'): %s", eaname, strerror(errno)); switch (errno) { case EPERM: @@ -1768,10 +1760,7 @@ int ea_chmod_dir(VFS_FUNC_ARGS_SETDIRUNIXMODE) } exit: - if (seteuid(uid) < 0) { - LOG(log_error, logtype_afpd, "can't seteuid back: %s", strerror(errno)); - exit(EXITERR_SYS); - } + unbecome_root(); if ((ea_close(&ea)) != 0) { LOG(log_error, logtype_afpd, "ea_chmod_dir('%s'): error closing ea handle", name);