/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
/*
* with functions renamed as part of a tentative plan for convergence.
*/
#ifndef _KERNEL
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
#include <syslog.h>
#include <ctype.h>
#include <assert.h>
#else /* _KERNEL */
#endif /* _KERNEL */
#include <sidutil.h>
/*
* sid_len
*
* Returns the number of bytes required to hold the sid.
*/
int
{
return (0);
}
/*
* sid_tostr
*
* Fill in the passed buffer with the string form of the given
* binary sid.
*/
void
{
char *p = strsid;
int i;
return;
while (*p)
p++;
for (i = 0; i < NT_SID_AUTH_MAX; ++i) {
while (*p)
p++;
}
}
while (*p)
p++;
}
}
/*
* sid_fromstr
*
* Converts a SID in string form to a SID structure. There are lots of
* simplifying assumptions in here. The memory for the SID is allocated
* as if it was the largest possible SID; the caller is responsible for
* freeing the memory when it is no longer required. We assume that the
* string starts with "S-1-" and that the authority is held in the last
* byte, which should be okay for most situations. It also assumes the
* sub-authorities are in decimal format.
*
* On success, a pointer to a SID is returned. Otherwise a null pointer
* is returned.
*/
sid_t *
{
char *p;
int size;
uint8_t i;
return (NULL);
return (NULL);
return (NULL);
while (*p && *p == '-')
++p;
if (*p < '0' || *p > '9') {
return (NULL);
}
while (*p && *p != '-')
++p;
}
sid->sid_subauthcnt = i;
return (sid);
}
void
{
#ifdef _KERNEL
return;
#else
#endif
}
void
{
int i;
p[0] = v & 0xff;
p[1] = (v >> 8) & 0xff;
p[2] = (v >> 16) & 0xff;
p[3] = (v >> 24) & 0xff;
}
}
void
{
int i;
uint32_t v;
v = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
sid->sid_subauth[i] = v;
}
}
/*
* Yet another along the lines of strncpy and strlcpy, neither of which
* do quite what's needed here.
*
* Out points at a buffer of size outlen.
* Copy from in no more than inbytes bytes.
* Ensure that out is null terminated.
*
* Perhaps this should assert that the result does not overflow outlen.
*/
static void
{
int n;
n = inbytes;
else
n = outlen-1;
while (n > 0 && *in != '\0') {
n--;
}
*out = '\0';
}
/*
* Given a properly formatted SID, split it into a prefix and a RID.
*/
void
char *sidprefix,
const char *sid)
{
const char *p;
}
/*
* Check to see if the specified string looks like a SID.
* Beyond the basic "looks like" test, this is mostly intended to ensure
* that you can do stuff like split off a RID or parse into a fixed-length
* buffer without additional checking.
*
* Not quite comprehensive: doesn't check whether the individual fields
* are too long.
*/
{
int nsubauth;
/* Require version 1 SID */
return (B_FALSE);
sid += 4;
/* Require an authority */
return (B_FALSE);
sid++;
/* Require at least one subauthority, but not too many. */
nsubauth = 0;
do {
if (++nsubauth > NT_SID_SUBAUTH_MAX)
return (B_FALSE);
if (*sid++ != '-')
return (B_FALSE);
return (B_FALSE);
sid++;
} while (*sid != '\0');
/* Don't let it be unreasonably long */
return (B_FALSE);
return (B_TRUE);
}