srvsvc_client.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"
/*
* Server Service (srvsvc) client side RPC library interface. The
* srvsvc interface allows a client to query a server for information
* on shares, sessions, connections and files on the server. Some
* functions are available via anonymous IPC while others require
* administrator privilege. Also, some functions return NT status
* values while others return Win32 errors codes.
*/
#include <stdio.h>
#include <time.h>
#include <strings.h>
#include <time.h>
#include <smbsrv/libsmbrdr.h>
#include <smbsrv/ntstatus.h>
#include <smbsrv/mlsvc_util.h>
/*
* Information level for NetShareGetInfo.
*/
/*
* Ensure that an appropriate session and logon exists for the srvsvc
* client calls. Open and bind the RPC interface.
*
* On success 0 is returned. Otherwise a -ve error code.
*/
int
{
int fid;
int rc;
return (-1);
}
switch (ipc_mode) {
case MLSVC_IPC_USER:
/*
* Use the supplied credentials.
*/
break;
case MLSVC_IPC_ADMIN:
/*
* Use the resource domain administrator credentials.
*/
break;
case MLSVC_IPC_ANON:
default:
break;
}
if (rc != 0)
return (-1);
if (fid < 0)
return (-1);
(void) mlsvc_close_pipe(fid);
return (rc);
}
return (rc);
}
/*
* Close the srvsvc pipe and free the associated context. This function
* should only be called if the open was successful.
*/
void
{
}
/*
* This is a client side routine for NetShareGetInfo.
* Levels 0 and 1 work with an anonymous connection but
* level 2 requires administrator access.
*/
int
{
struct mlsm_NetShareGetInfo arg;
int rc;
int opnum;
struct mslm_NetShareGetInfo0 *info0;
struct mslm_NetShareGetInfo1 *info1;
struct mslm_NetShareGetInfo2 *info2;
int ipc_mode;
int len;
return (-1);
if (srvsvc_info_level == 2)
else
if (rc != 0)
return (-1);
return (-1);
}
return (-1);
}
case 0:
break;
case 1:
if (info1->shi1_comment)
smb_tracef("srvsvc shi1_comment=%s",
break;
case 2:
if (info2->shi2_comment)
smb_tracef("srvsvc shi2_comment=%s",
if (info2->shi2_passwd)
break;
default:
smb_tracef("srvsvc: unknown level");
break;
}
return (0);
}
/*
* This is a client side routine for NetSessionEnum.
* NetSessionEnum requires administrator rights.
*/
int
{
struct mslm_NetSessionEnum arg;
int rc;
int opnum;
struct mslm_infonres infonres;
struct mslm_SESSION_INFO_1 *nsi1;
int len;
return (-1);
if (rc != 0)
return (-1);
return (-1);
}
infonres.entriesread = 0;
arg.resume_handle = 0;
return (-1);
}
/* Only the first session info is dereferenced. */
return (0);
}
/*
* This is a client side routine for NetConnectEnum.
* NetConnectEnum requires administrator rights.
* Level 0 and level 1 requests are supported.
*/
int
{
struct mslm_NetConnectEnum arg;
int rc;
int opnum;
struct mslm_NetConnectInfo1 info1;
struct mslm_NetConnectInfo0 info0;
struct mslm_NetConnectInfoBuf1 *cib1;
int len;
return (-1);
if (rc != 0)
return (-1);
return (-1);
}
switch (level) {
case 0:
info0.entries_read = 0;
break;
case 1:
info1.entries_read = 0;
break;
default:
return (-1);
}
arg.resume_handle = 0;
return (-1);
}
switch (level) {
case 0:
smb_tracef("srvsvc coni0_id=%x",
}
break;
case 1:
smb_tracef("srvsvc coni_uname=%s",
smb_tracef("srvsvc coni1_netname=%s",
smb_tracef("srvsvc coni1_nopens=%u",
smb_tracef("srvsvc coni1_num_users=%u",
}
break;
default:
smb_tracef("srvsvc: unknown level");
break;
}
return (0);
}
/*
* Synchronize the local system clock with the domain controller.
*/
void
srvsvc_timesync(void)
{
return;
return;
if (settimeofday(&tv, 0))
smb_tracef("unable to set system time");
}
/*
* NetRemoteTOD to get the current GMT time from a Windows NT server.
*/
int
srvsvc_gettime(unsigned long *t)
{
return (-1);
return (-1);
return (0);
}
/*
* This is a client side routine for NetRemoteTOD, which gets the time
* and date from a remote system. The time information is returned in
* the timeval and tm.
*
* typedef struct _TIME_OF_DAY_INFO {
* DWORD tod_elapsedt; // seconds since 00:00:00 January 1 1970 GMT
* DWORD tod_msecs; // arbitrary milliseconds (since reset)
* DWORD tod_hours; // current hour [0-23]
* DWORD tod_mins; // current minute [0-59]
* DWORD tod_secs; // current second [0-59]
* DWORD tod_hunds; // current hundredth (0.01) second [0-99]
* LONG tod_timezone; // time zone of the server
* DWORD tod_tinterval; // clock tick time interval
* DWORD tod_day; // day of the month [1-31]
* DWORD tod_month; // month of the year [1-12]
* DWORD tod_year; // current year
* DWORD tod_weekday; // day of the week since sunday [0-6]
* } TIME_OF_DAY_INFO;
*
* The time zone of the server is calculated in minutes from Greenwich
* Mean Time (GMT). For time zones west of Greenwich, the value is
* positive; for time zones east of Greenwich, the value is negative.
* A value of -1 indicates that the time zone is undefined.
*
* The clock tick value represents a resolution of one ten-thousandth
* (0.0001) second.
*/
int
{
char timebuf[64];
struct mslm_NetRemoteTOD arg;
struct mslm_TIME_OF_DAY_INFO *tod;
int rc;
int opnum;
int len;
if (rc != 0)
return (-1);
return (-1);
}
return (-1);
}
/*
* We're assigning milliseconds to microseconds
* here but the value's not really relevant.
*/
if (tv) {
}
if (tm) {
"NetRemoteTOD: %D %T", tm);
}
return (0);
}
void
{
}
#if 0
/*
* The NetSessionEnum server-side definition was updated.
* Disabled until the client-side has been updated.
*/
#endif
}