smb_autohome.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>
#include <smbsrv/libmlsvc.h>
#define SMB_AUTOHOME_KEYSIZ 128
#define SMB_AUTOHOME_MAXARG 4
#define SMB_AUTOHOME_BUFSIZ 2048
typedef struct smb_autohome_info {
struct smb_autohome_info *magic1;
char buf[SMB_AUTOHOME_BUFSIZ];
char *argv[SMB_AUTOHOME_MAXARG];
int lineno;
struct smb_autohome_info *magic2;
static smb_autohome_info_t smb_ai;
static char *smb_autohome_keysub(const char *, char *, int);
static smb_autohome_info_t *smb_autohome_getinfo(void);
/*
* Add an autohome share. See smb_autohome(4) for details.
*
* If share directory contains backslash path separators, they will
* autohome shares.
*
* Returns 0 on success or -1 to indicate an error.
*/
int
smb_autohome_add(const char *username)
{
char *sharename;
return (-1);
return (-1);
return (0);
}
return (0);
}
if (lmshare_exists(sharename) != 0) {
return (0);
}
} else {
}
(void) lmshare_add(&si, 0);
return (0);
}
/*
* Remove an autohome share.
*
* Returns 0 on success or -1 to indicate an error.
*/
int
smb_autohome_remove(const char *username)
{
char *sharename;
return (-1);
return (-1);
(void) lmshare_delete(sharename, 0);
}
}
return (0);
}
/*
* Find out if a share is an autohome share.
*
* Returns 1 if the share is an autohome share.
* Otherwise returns 0.
*/
int
{
return (1);
}
return (0);
}
/*
* Search the autohome database for the specified name. The name cannot
* be an empty string or begin with * or +.
* 1. Search the file for the specified name.
* 2. Check for the wildcard rule and, if present, treat it as a match.
* 3. Check for the nsswitch rule and, if present, lookup the name
* via the name services. Note that the nsswitch rule will never
* be applied if the wildcard rule is present.
*
* Returns a pointer to the entry on success or null on failure.
*/
smb_autohome_lookup(const char *name)
{
smb_autohome_t *ah = 0;
return (NULL);
return (NULL);
break;
}
break;
}
}
}
continue;
ah = 0;
break;
}
break;
}
}
return (ah);
}
/*
* Open or rewind the autohome database.
*/
void
smb_autohome_setent(void)
{
char *mappath;
char filename[MAXNAMELEN];
if ((si = smb_autohome_getinfo()) != 0) {
return;
}
return;
return;
}
/*
* Close the autohome database and invalidate the autohome info.
* We can't zero the whole info structure because the application
* should still have access to the data after the file is closed.
*/
void
smb_autohome_endent(void)
{
if ((si = smb_autohome_getinfo()) != 0) {
}
}
/*
* Return the next entry in the autohome database, opening the file
* if necessary. Returns null on EOF or error.
*
* Note that we are not looking for the specified name. The name is
* only used for key substitution, so that the caller sees the entry
* in expanded form.
*/
smb_autohome_getent(const char *name)
{
char *bp;
if ((si = smb_autohome_getinfo()) == 0) {
if ((si = smb_autohome_getinfo()) == 0)
return (0);
}
/*
* Find the next non-comment, non-empty line.
* Anything after a # is a comment and can be discarded.
* Discard a newline to avoid it being included in the parsing
* that follows.
* Leading and training whitespace is discarded, and replicated
* whitespace is compressed to simplify the token parsing,
* although strsep() deals with that better than strtok().
*/
do {
return (0);
*bp = '\0';
} while (*bp == '\0');
return (smb_autohome_make_entry(si));
}
/*
* Set up an autohome entry from the line buffer. The line should just
* contain tokens separated by single whitespace. The line format is:
* <username> <home-dir-path> <ADS container>
*/
static smb_autohome_t *
{
char *bp;
int i;
for (i = 0; i < SMB_AUTOHOME_MAXARG; ++i)
for (i = 0; i < SMB_AUTOHOME_MAXARG; ++i) {
do {
break;
break;
}
/*
* Sanity check: the name could be an empty
* string but it can't be a null pointer.
*/
return (0);
}
}
/*
* Substitute the ? and & map keys.
* ? is replaced by the first character of the name
* & is replaced by the whole name.
*/
static char *
{
char key[SMB_AUTOHOME_KEYSIZ];
char *ampersand;
char *tmp;
return (NULL);
*tmp = '\0';
return (0);
}
return (buf);
}
/*
* Get a pointer to the context buffer and validate it.
*/
static smb_autohome_info_t *
smb_autohome_getinfo(void)
{
return (0);
return (si);
return (0);
}