newlib/winsup/cygwin/cygserver.h
Corinna Vinschen 29b7313d22 * cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.
(cygheap_pwdgrp::caching): Convert to bool.
	(cygheap_pwdgrp::pwd_cache): Add cygserver member.
	(cygheap_pwdgrp::grp_cache): Ditto.
	(cygheap_pwdgrp::nss_db_caching): Drop.
	(cygheap_pwdgrp::nss_db_full_caching): Drop.
	(cygheap_pwdgrp::nss_cygserver_caching): New method.
	(cygheap_pwdgrp::nss_disable_cygserver_caching): New method.
	* cygserver.h (client_request::request_code_t): Add
	CYGSERVER_REQUEST_PWDGRP.
	* cygserver_pwdgrp.h: New file.
	* cygtls.h (struct _local_storage): Remove pwbuf and grbuf members.
	* grp.cc (pwdgrp::prep_tls_grbuf): Drop.
	(internal_getgrsid): Handle cygserver caching and rearrange to check
	the caches first.
	(internal_getgrnam): Ditto.
	(internal_getgrgid): Ditto.
	(gr_ent::enumerate_caches): Handle cygserver cache.
	* passwd.cc (pwdgrp::prep_tls_pwbuf): Drop.
	(internal_getpwsid): Handle cygserver caching and rearrange to check
	the caches first.
	(internal_getpwnam): Ditto.
	(internal_getpwuid): Ditto.
	(pw_ent::enumerate_caches): Handle cygserver cache.
	* pwdgrp.h (pwdgrp::add_account_from_cygserver): New method declaration.
	(pwdgrp::fetch_account_from_cygserver): New method declaration.
	(pwdgrp::prep_tls_pwbuf): Drop declaration.
	(pwdgrp::prep_tls_grbuf): Drop declaration.
	(pwdgrp::add_user_from_cygserver): New inline methods.
	(pwdgrp::add_group_from_cygserver): New inline methods.
	* tlsoffsets.h: Regenerate.
	* tlsoffsets64.h: Regenerate.
	* uinfo.cc (internal_getlogin): Call internal_getgroups if cygserver
	caching is not available.
	(cygheap_pwdgrp::init): Initialize pwd_cache.cygserver and
	grp_cache.cygserver.  Set caching to true.
	(cygheap_pwdgrp::nss_init_line): Drop db_cache handling entirely.
	(pwdgrp::add_account_from_windows): Drop no caching handling.
	(client_request_pwdgrp::client_request_pwdgrp): New method.
	(pwdgrp::fetch_account_from_cygserver): New method.
	(pwdgrp::add_account_from_cygserver): New method.

	* fhandler_disk_file.cc (fhandler_base::fstat_helper): Fix formatting.
	* include/sys/cygwin.h: Ditto.
2014-03-12 17:36:56 +00:00

193 lines
4.5 KiB
C++

/* cygserver.h
Copyright 2001, 2002, 2003, 2004, 2008, 2012, 2013 Red Hat Inc.
Written by Egor Duda <deo@logos-m.ru>
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _CYGSERVER_H_
#define _CYGSERVER_H_
#ifdef __GNUC__
#define CYGSERVER_PACKED __attribute__ ((packed))
#else
#define CYGSERVER_PACKED
#endif
#define CYGWIN_SERVER_VERSION_MAJOR 1
#define CYGWIN_SERVER_VERSION_API 4
#define CYGWIN_SERVER_VERSION_MINOR 0
#define CYGWIN_SERVER_VERSION_PATCH 0
typedef enum {
CYGSERVER_UNKNOWN = 0,
CYGSERVER_OK,
CYGSERVER_UNAVAIL
} cygserver_states;
/*---------------------------------------------------------------------------*
* class client_request
*---------------------------------------------------------------------------*/
class transport_layer_base;
#ifndef __INSIDE_CYGWIN__
class process_cache;
#endif
class client_request
{
protected:
typedef enum {
CYGSERVER_REQUEST_INVALID,
CYGSERVER_REQUEST_GET_VERSION,
CYGSERVER_REQUEST_SHUTDOWN,
CYGSERVER_REQUEST_ATTACH_TTY,
CYGSERVER_REQUEST_MSG,
CYGSERVER_REQUEST_SEM,
CYGSERVER_REQUEST_SHM,
CYGSERVER_REQUEST_SETPWD,
CYGSERVER_REQUEST_PWDGRP,
CYGSERVER_REQUEST_LAST
} request_code_t;
struct header_t
{
size_t msglen;
union
{
request_code_t request_code;
int error_code;
};
header_t () {};
header_t (request_code_t, size_t);
} CYGSERVER_PACKED;
public:
#ifndef __INSIDE_CYGWIN__
static void handle_request (transport_layer_base *, process_cache *);
#endif
client_request (request_code_t request_code,
void *buf = NULL,
size_t bufsiz = 0);
virtual ~client_request ();
request_code_t request_code () const { return _header.request_code; }
int error_code () const { return _header.error_code; };
void error_code (int error_code) { _header.error_code = error_code; };
size_t msglen () const { return _header.msglen; };
void msglen (size_t len) { _header.msglen = len; };
int make_request ();
protected:
virtual void send (transport_layer_base *);
private:
header_t _header;
void * const _buf;
const size_t _buflen;
#ifndef __INSIDE_CYGWIN__
void handle (transport_layer_base *, process_cache *);
virtual void serve (transport_layer_base *, process_cache *) = 0;
#endif
};
/*---------------------------------------------------------------------------*
* class client_request_get_version
*---------------------------------------------------------------------------*/
class client_request_get_version : public client_request
{
private:
struct request_get_version
{
DWORD major, api, minor, patch;
} CYGSERVER_PACKED;
public:
client_request_get_version ();
bool check_version () const;
private:
struct request_get_version version;
#ifndef __INSIDE_CYGWIN__
virtual void serve (transport_layer_base *, process_cache *);
#endif
};
/*---------------------------------------------------------------------------*
* class client_request_shutdown
*
* Nb. This whole class is only !__INSIDE_CYGWIN__ since it is used
* solely by cygserver itself.
*---------------------------------------------------------------------------*/
#ifndef __INSIDE_CYGWIN__
class client_request_shutdown : public client_request
{
public:
client_request_shutdown ();
private:
virtual void serve (transport_layer_base *, process_cache *);
};
#endif /* !__INSIDE_CYGWIN__ */
/*---------------------------------------------------------------------------*
* class client_request_attach_tty
*---------------------------------------------------------------------------*/
class client_request_attach_tty : public client_request
{
private:
struct request_attach_tty
{
DWORD pid, master_pid;
HANDLE from_master, to_master;
} CYGSERVER_PACKED;
public:
#ifdef __INSIDE_CYGWIN__
client_request_attach_tty (DWORD nmaster_pid,
HANDLE nfrom_master, HANDLE nto_master);
#else
client_request_attach_tty ();
#endif
HANDLE from_master () const { return req.from_master; };
HANDLE to_master () const { return req.to_master; };
protected:
virtual void send (transport_layer_base *);
private:
struct request_attach_tty req;
#ifndef __INSIDE_CYGWIN__
virtual void serve (transport_layer_base *, process_cache *);
#endif
};
#ifndef __INSIDE_CYGWIN__
extern PSID admininstrator_group_sid;
#endif
extern bool check_cygserver_available ();
extern void cygserver_init ();
#endif /* _CYGSERVER_H_ */