From 31bda62b05fe69efe7d54188c74dcee936064f4d Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 6 Dec 2012 13:06:14 +0100 Subject: [PATCH 1/1] Add support for quoting in '[in]valid users' option As the option should allow spaces in names, but we use comma and space as field delimiter, add support for quoting names. Fixes bug #472. --- NEWS | 2 ++ libatalk/util/netatalk_conf.c | 11 +++++++---- man/man5/afp.conf.5.tmpl | 24 +++++++++++++++--------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index cb28553f..9ae8ad59 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,8 @@ Changes in 3.0.2 * FIX: Fix an error where catalog search gave incomplete results. Fixes bug #479. * REM: Remove TimeMachine volume used size FCE event. +* UPD: Add quoting support to '[in]valid users' option. + Fixes bug #472. Changes in 3.0.1 ================ diff --git a/libatalk/util/netatalk_conf.c b/libatalk/util/netatalk_conf.c index 338394e1..01c6cb97 100644 --- a/libatalk/util/netatalk_conf.c +++ b/libatalk/util/netatalk_conf.c @@ -401,8 +401,11 @@ static char *volxlate(const AFPObj *obj, /*! * check access list * - * this function wants something of the following form: - * "@group,name,name2,@group2,name3" or "@group name name2 @group2 name3" + * this function wants a string consisting of names seperated by comma + * or space. Names may be quoted within a pair of quotes. Groups are + * denoted by a leading @ symbol. + * Example: + * user1 user2, user3, @group1 @group2, @group3 "user name1", "@group name1" * A NULL argument allows everybody to have access. * We return three things: * -1: no list @@ -420,7 +423,7 @@ static int accessvol(const AFPObj *obj, const char *args, const char *name) EC_NULL_LOG( names = strdup(args) ); - if ((p = strtok(names, ", ")) == NULL) /* nothing, return okay */ + if ((p = strtok_quote(names, ", ")) == NULL) /* nothing, return okay */ EC_EXIT_STATUS(-1); while (p) { @@ -429,7 +432,7 @@ static int accessvol(const AFPObj *obj, const char *args, const char *name) EC_EXIT_STATUS(1); } else if (strcasecmp(p, name) == 0) /* it's a user name */ EC_EXIT_STATUS(1); - p = strtok(NULL, ", "); + p = strtok_quote(NULL, ", "); } EC_CLEANUP: diff --git a/man/man5/afp.conf.5.tmpl b/man/man5/afp.conf.5.tmpl index e0ba2649..d2bbf43a 100644 --- a/man/man5/afp.conf.5.tmpl +++ b/man/man5/afp.conf.5.tmpl @@ -2,12 +2,12 @@ .\" Title: afp.conf .\" Author: [FIXME: author] [see http://docbook.sf.net/el/author] .\" Generator: DocBook XSL Stylesheets v1.75.2 -.\" Date: 22 Nov 2012 +.\" Date: 06 Dez 2012 .\" Manual: Netatalk 3.0 .\" Source: Netatalk 3.0 .\" Language: English .\" -.TH "AFP\&.CONF" "5" "22 Nov 2012" "Netatalk 3.0" "Netatalk 3.0" +.TH "AFP\&.CONF" "5" "06 Dez 2012" "Netatalk 3.0" "Netatalk 3.0" .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- @@ -699,7 +699,6 @@ sasl .RS 4 SASL\&. Not yet supported ! .RE -.sp .RE .PP ldap auth dn = \fIdn\fR \fB(G)\fR @@ -775,7 +774,6 @@ ms\-guid .RS 4 Binary objectGUID from Active Directory .RE -.sp .RE .PP ldap group attr = \fIdn\fR \fB(G)\fR @@ -811,9 +809,19 @@ Useful for Time Machine: limits the reported volume size, thus preventing Time M This is an approimated calculation taking into accout the contents of Time Machine sparsebundle images\&. Therefor you MUST NOT use this volume to store other content when using this option, because it would NOT be accounted\&. The calculation works by reading the band size from the Info\&.plist XML file of the sparsebundle, reading the bands/ directory counting the number of band files, and then multiplying one with the other\&. .RE .PP -valid users = \fIusers/groups\fR \fB(V)\fR +valid users = \fIuser @group\fR \fB(V)\fR .RS 4 -The allow option allows the users and groups that access a share to be specified\&. Users and groups are specified, delimited by spaces or commas\&. Groups are designated by a @ prefix\&. Example: "valid users = user1 user2 @group" +The allow option allows the users and groups that access a share to be specified\&. Users and groups are specified, delimited by spaces or commas\&. Groups are designated by a @ prefix\&. Names may be quoted in order to allow for spaces in names\&. Example: +.sp +.if n \{\ +.RS 4 +.\} +.nf +valid users = user "user 2" @group \(lq@group 2" +.fi +.if n \{\ +.RE +.\} .RE .PP invalid users = \fIusers/groups\fR \fB(V)\fR @@ -914,7 +922,6 @@ is for files only, is for directories only\&. Don\'t use with "\fBunix priv = no\fR"\&. .PP \fBExample.\ \&Volume for a collaborative workgroup\fR - .sp .if n \{\ .RS 4 @@ -926,7 +933,6 @@ file perm = 0660 directory perm = .if n \{\ .RE .\} -.sp .RE .PP @@ -1111,7 +1117,7 @@ The option will allow you to select another volume encoding\&. E\&.g\&. for western users another useful setting could be vol charset ISO\-8859\-15\&. \fBafpd\fR will accept any -\fB iconv \fR(1) +\fBiconv\fR(1) provided charset\&. If a character cannot be converted from the \fBmac charset\fR to the selected -- 2.39.2