|
Packit |
b0b924 |
/* Copyright (c) 2006 The Regents of the University of Michigan.
|
|
Packit |
b0b924 |
* All rights reserved.
|
|
Packit |
b0b924 |
*
|
|
Packit |
b0b924 |
* David M. Richter <richterd@citi.umich.edu>
|
|
Packit |
b0b924 |
*
|
|
Packit |
b0b924 |
* Redistribution and use in source and binary forms, with or without
|
|
Packit |
b0b924 |
* modification, are permitted provided that the following conditions
|
|
Packit |
b0b924 |
* are met:
|
|
Packit |
b0b924 |
*
|
|
Packit |
b0b924 |
* 1. Redistributions of source code must retain the above copyright
|
|
Packit |
b0b924 |
* notice, this list of conditions and the following disclaimer.
|
|
Packit |
b0b924 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
Packit |
b0b924 |
* notice, this list of conditions and the following disclaimer in the
|
|
Packit |
b0b924 |
* documentation and/or other materials provided with the distribution.
|
|
Packit |
b0b924 |
* 3. Neither the name of the University nor the names of its
|
|
Packit |
b0b924 |
* contributors may be used to endorse or promote products derived
|
|
Packit |
b0b924 |
* from this software without specific prior written permission.
|
|
Packit |
b0b924 |
*
|
|
Packit |
b0b924 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
Packit |
b0b924 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
Packit |
b0b924 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
b0b924 |
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
Packit |
b0b924 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
b0b924 |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
b0b924 |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
Packit |
b0b924 |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
Packit |
b0b924 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
Packit |
b0b924 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit |
b0b924 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
b0b924 |
*/
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
#include <string.h>
|
|
Packit |
b0b924 |
#include "libacl_nfs4.h"
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
/*
|
|
Packit |
b0b924 |
* nfs4_insert_string_aces - read ACE entries from spec string into struct nfs4_acl
|
|
Packit |
b0b924 |
*/
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
int nfs4_insert_string_aces(struct nfs4_acl *acl, const char *acl_spec, unsigned int index)
|
|
Packit |
b0b924 |
{
|
|
Packit |
b0b924 |
char *s, *sp, *ssp;
|
|
Packit |
b0b924 |
struct nfs4_ace *ace;
|
|
Packit |
b0b924 |
int res = 0;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
if ((s = sp = strdup(acl_spec)) == NULL)
|
|
Packit |
b0b924 |
goto out_failed;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
while ((ssp = strsep(&sp, ",\t\n\r")) != NULL) {
|
|
Packit |
b0b924 |
if (!strlen(ssp))
|
|
Packit |
b0b924 |
continue;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
if ((ace = nfs4_ace_from_string(ssp, acl->is_directory)) == NULL)
|
|
Packit |
b0b924 |
goto out_failed;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
if (nfs4_insert_ace_at(acl, ace, index++)) {
|
|
Packit |
b0b924 |
free(ace);
|
|
Packit |
b0b924 |
goto out_failed;
|
|
Packit |
b0b924 |
}
|
|
Packit |
b0b924 |
}
|
|
Packit |
b0b924 |
if (acl->naces == 0)
|
|
Packit |
b0b924 |
goto out_failed;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
out:
|
|
Packit |
b0b924 |
if (s)
|
|
Packit |
b0b924 |
free(s);
|
|
Packit |
b0b924 |
return res;
|
|
Packit |
b0b924 |
|
|
Packit |
b0b924 |
out_failed:
|
|
Packit |
b0b924 |
res = -1;
|
|
Packit |
b0b924 |
goto out;
|
|
Packit |
b0b924 |
}
|