/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1995 Sun Microsystems, Inc. All Rights Reserved
*
* module:
* acls.c
*
* purpose:
* routines to manipulate access control lists, mapping between
* the data structures required by the filesystem ACL system calls
* and the representation used in our fileinfo structure.
*
*/
#ident "%W% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include "filesync.h"
#include "database.h"
#ifdef NO_ACLS
/*
* Solaris 2.4 libc.so does not contain this entry point, so if we
* want to build a 2.4 version of filesync, we need to provide a
* dummy entry point that will fail when-ever it is called.
*/
{
return (-1);
}
#endif
/*
* routine:
* get_acls
*
* purpose:
* to read the ACL (if any) from a file into a fileinfo structure
*
* parameters:
* name of file
* pointer to fileinfo structure
*
* returns:
* number of ACL entries
*/
int
{ int count;
int i;
if (count <= 0)
return (0);
/* with a count of 3 or 4 there may not be any real ones */
if (count > 4)
goto gotsome;
/* look for anything beyond the normal unix protection */
for (i = 0; i < count; i++)
default: /* weird types are real */
goto gotsome;
case USER_OBJ:
case GROUP_OBJ:
case OTHER_OBJ:
case CLASS_OBJ:
continue; /* all file have these */
}
return (0); /* nothing interesting */
/* allocate an array to hold the acls */
if (list == 0)
nomem("Access Control List");
/* copy the acls into the new list */
for (i = 0; i < count; i++) {
}
}
/*
* routine:
* cmp_acls
*
* purpose:
* determine whether or not two ACLs are the same
*
* parameters:
* pointer to first fileinfo
* pointer to second fileinfo
*
* returns:
* true equal
* false different
*/
int
{ int i;
return (0);
return (1);
return (0);
return (0);
return (0);
}
return (1);
}
/*
* routine:
* set_acls
*
* purpose:
* to write the ACL of a file
*
* parameters:
* name of file
* fileinfo pointer (which contains an acl pointer)
*
* returns:
* retcode and errno
*/
int
{ int rc;
int nacl;
/* fabricate a standard set of bogus ACLs */
nacl = 4;
} else {
}
/* non-negative number mean success */
if (rc < 0)
return (rc);
else
return (0);
}
/*
* routine:
* show_acls
*
* purpose:
* to map an acl into arguments for a setfacl command
*
* paramters:
* number of elements in list
* pointer to list
*
* returns:
* pointer to character buffer containing arguments
*/
char
{ int i, j;
char *s;
s = buf;
if (numacl > 0) {
*s++ = '-';
*s++ = 's';
*s++ = ' ';
} else {
*s++ = '-';
*s++ = 'd';
}
for (i = 0; i < numacl; i++) {
if (i > 0)
*s++ = ',';
/* note whether this is per-file or default */
if (type & ACL_DEFAULT) {
*s++ = 'd';
*s++ = ':';
}
/* print out the entry type */
*s++ = 'u';
*s++ = ':';
*s++ = 'g';
*s++ = ':';
*s++ = 'o';
*s++ = ':';
*s++ = 'm';
*s++ = ':';
}
/* print out the ID for this ACL */
*s++ = ':';
while (j > 0) {
*s++ = '0' + (id/j);
id %= j*10;
j /= 10;
}
*s++ = ':';
}
/* print out the permissions for this ACL */
}
*s = 0;
return (buf);
}