[PATCH] nss_linux: Remove non-nss functions
Jeremy Allison
jra at samba.org
Thu Feb 11 00:31:27 UTC 2016
On Tue, Feb 09, 2016 at 07:58:05AM +0100, Volker Lendecke wrote:
> Hi!
>
> Can we do that? I can't imagine anyone using them.
>
> Comments appreciated!
LGTM. Pushed !
> SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
> phone: +49-551-370000-0, fax: +49-551-370000-9
> AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
> http://www.sernet.de, mailto:kontakt at sernet.de
> From 7ce11c9229f0eb8833d99fd3454d58e35cc88690 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Tue, 9 Feb 2016 07:50:10 +0100
> Subject: [PATCH 1/2] nss_linux: Remove non-nss functions
>
> These functions were meant as a standard interface before libwbclient was
> developed.
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> nsswitch/winbind_nss_linux.c | 371 -------------------------------------------
> 1 file changed, 371 deletions(-)
>
> diff --git a/nsswitch/winbind_nss_linux.c b/nsswitch/winbind_nss_linux.c
> index 3099413..2b31bac 100644
> --- a/nsswitch/winbind_nss_linux.c
> +++ b/nsswitch/winbind_nss_linux.c
> @@ -57,19 +57,6 @@ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer
> NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
> long int *size, gid_t **groups,
> long int limit, int *errnop);
> -NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
> - int *num_groups, char *buffer, size_t buf_size,
> - int *errnop);
> -NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop);
> -NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop);
> -NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
> - size_t buflen, int *errnop);
>
> /*************************************************************************
> ************************************************************************/
> @@ -1158,361 +1145,3 @@ _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
>
> return ret;
> }
> -
> -
> -/* return a list of group SIDs for a user SID */
> -NSS_STATUS
> -_nss_winbind_getusersids(const char *user_sid, char **group_sids,
> - int *num_groups,
> - char *buffer, size_t buf_size, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_request request;
> - struct winbindd_response response;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5d]: getusersids %s\n", getpid(), user_sid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(request);
> - ZERO_STRUCT(response);
> -
> - strncpy(request.data.sid, user_sid,sizeof(request.data.sid) - 1);
> - request.data.sid[sizeof(request.data.sid) - 1] = '\0';
> -
> - ret = winbindd_request_response(NULL, WINBINDD_GETUSERSIDS,
> - &request, &response);
> -
> - if (ret != NSS_STATUS_SUCCESS) {
> - goto done;
> - }
> -
> - if (buf_size < response.length - sizeof(response)) {
> - ret = NSS_STATUS_TRYAGAIN;
> - errno = *errnop = ERANGE;
> - goto done;
> - }
> -
> - *num_groups = response.data.num_entries;
> - *group_sids = buffer;
> - memcpy(buffer, response.extra_data.data, response.length - sizeof(response));
> - errno = *errnop = 0;
> -
> - done:
> - winbindd_free_response(&response);
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -
> -/* map a user or group name to a SID string */
> -NSS_STATUS
> -_nss_winbind_nametosid(const char *name, char **sid, char *buffer,
> - size_t buflen, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5d]: nametosid %s\n", getpid(), name);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(response);
> - ZERO_STRUCT(request);
> -
> - strncpy(request.data.name.name, name,
> - sizeof(request.data.name.name) - 1);
> - request.data.name.name[sizeof(request.data.name.name) - 1] = '\0';
> -
> - ret = winbindd_request_response(NULL, WINBINDD_LOOKUPNAME,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - if (buflen < strlen(response.data.sid.sid)+1) {
> - ret = NSS_STATUS_TRYAGAIN;
> - *errnop = errno = ERANGE;
> - goto failed;
> - }
> -
> - *errnop = errno = 0;
> - *sid = buffer;
> - strcpy(*sid, response.data.sid.sid);
> -
> -failed:
> - winbindd_free_response(&response);
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -/* map a sid string to a user or group name */
> -NSS_STATUS
> -_nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
> - size_t buflen, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> - static char sep_char;
> - unsigned needed;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5d]: sidtoname %s\n", getpid(), sid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(response);
> - ZERO_STRUCT(request);
> -
> - /* we need to fetch the separator first time through */
> - if (!sep_char) {
> - ret = winbindd_request_response(NULL, WINBINDD_INFO,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - sep_char = response.data.info.winbind_separator;
> - winbindd_free_response(&response);
> - }
> -
> -
> - strncpy(request.data.sid, sid,
> - sizeof(request.data.sid) - 1);
> - request.data.sid[sizeof(request.data.sid) - 1] = '\0';
> -
> - ret = winbindd_request_response(NULL, WINBINDD_LOOKUPSID,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - needed =
> - strlen(response.data.name.dom_name) +
> - strlen(response.data.name.name) + 2;
> -
> - if (buflen < needed) {
> - ret = NSS_STATUS_TRYAGAIN;
> - *errnop = errno = ERANGE;
> - goto failed;
> - }
> -
> - snprintf(buffer, needed, "%s%c%s",
> - response.data.name.dom_name,
> - sep_char,
> - response.data.name.name);
> -
> - *name = buffer;
> - *errnop = errno = 0;
> -
> -failed:
> - winbindd_free_response(&response);
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -/* map a sid to a uid */
> -NSS_STATUS
> -_nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5d]: sidtouid %s\n", getpid(), sid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(request);
> - ZERO_STRUCT(response);
> -
> - strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
> - request.data.sid[sizeof(request.data.sid) - 1] = '\0';
> -
> - ret = winbindd_request_response(NULL, WINBINDD_SID_TO_UID,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - *uid = response.data.uid;
> -
> -failed:
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -/* map a sid to a gid */
> -NSS_STATUS
> -_nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5d]: sidtogid %s\n", getpid(), sid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(request);
> - ZERO_STRUCT(response);
> -
> - strncpy(request.data.sid, sid, sizeof(request.data.sid) - 1);
> - request.data.sid[sizeof(request.data.sid) - 1] = '\0';
> -
> - ret = winbindd_request_response(NULL, WINBINDD_SID_TO_GID,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - *gid = response.data.gid;
> -
> -failed:
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -/* map a uid to a SID string */
> -NSS_STATUS
> -_nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
> - size_t buflen, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5u]: uidtosid %u\n", (unsigned int)getpid(), (unsigned int)uid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(response);
> - ZERO_STRUCT(request);
> -
> - request.data.uid = uid;
> -
> - ret = winbindd_request_response(NULL, WINBINDD_UID_TO_SID,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - if (buflen < strlen(response.data.sid.sid)+1) {
> - ret = NSS_STATUS_TRYAGAIN;
> - *errnop = errno = ERANGE;
> - goto failed;
> - }
> -
> - *errnop = errno = 0;
> - *sid = buffer;
> - strcpy(*sid, response.data.sid.sid);
> -
> -failed:
> - winbindd_free_response(&response);
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> -
> -/* map a gid to a SID string */
> -NSS_STATUS
> -_nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
> - size_t buflen, int *errnop)
> -{
> - NSS_STATUS ret;
> - struct winbindd_response response;
> - struct winbindd_request request;
> -
> -#ifdef DEBUG_NSS
> - fprintf(stderr, "[%5u]: gidtosid %u\n", (unsigned int)getpid(), (unsigned int)gid);
> -#endif
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_lock(&winbind_nss_mutex);
> -#endif
> -
> - ZERO_STRUCT(response);
> - ZERO_STRUCT(request);
> -
> - request.data.gid = gid;
> -
> - ret = winbindd_request_response(NULL, WINBINDD_GID_TO_SID,
> - &request, &response);
> - if (ret != NSS_STATUS_SUCCESS) {
> - *errnop = errno = EINVAL;
> - goto failed;
> - }
> -
> - if (buflen < strlen(response.data.sid.sid)+1) {
> - ret = NSS_STATUS_TRYAGAIN;
> - *errnop = errno = ERANGE;
> - goto failed;
> - }
> -
> - *errnop = errno = 0;
> - *sid = buffer;
> - strcpy(*sid, response.data.sid.sid);
> -
> -failed:
> - winbindd_free_response(&response);
> -
> -#if HAVE_PTHREAD
> - pthread_mutex_unlock(&winbind_nss_mutex);
> -#endif
> -
> - return ret;
> -}
> --
> 1.9.1
>
>
> From 85bf84e5e5584c117019bacb6914c11a53036f28 Mon Sep 17 00:00:00 2001
> From: Volker Lendecke <vl at samba.org>
> Date: Tue, 9 Feb 2016 07:52:31 +0100
> Subject: [PATCH 2/2] nss_netbsd: Remove unimplemented prototypes
>
> Signed-off-by: Volker Lendecke <vl at samba.org>
> ---
> nsswitch/winbind_nss_netbsd.c | 13 -------------
> 1 file changed, 13 deletions(-)
>
> diff --git a/nsswitch/winbind_nss_netbsd.c b/nsswitch/winbind_nss_netbsd.c
> index eb843ee..d3a558c 100644
> --- a/nsswitch/winbind_nss_netbsd.c
> +++ b/nsswitch/winbind_nss_netbsd.c
> @@ -63,19 +63,6 @@ NSS_STATUS _nss_winbind_getgrgid_r(gid_t gid, struct group *result, char *buffer
> NSS_STATUS _nss_winbind_initgroups_dyn(char *user, gid_t group, long int *start,
> long int *size, gid_t **groups,
> long int limit, int *errnop);
> -NSS_STATUS _nss_winbind_getusersids(const char *user_sid, char **group_sids,
> - int *num_groups, char *buffer, size_t buf_size,
> - int *errnop);
> -NSS_STATUS _nss_winbind_nametosid(const char *name, char **sid, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_sidtoname(const char *sid, char **name, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_sidtouid(const char *sid, uid_t *uid, int *errnop);
> -NSS_STATUS _nss_winbind_sidtogid(const char *sid, gid_t *gid, int *errnop);
> -NSS_STATUS _nss_winbind_uidtosid(uid_t uid, char **sid, char *buffer,
> - size_t buflen, int *errnop);
> -NSS_STATUS _nss_winbind_gidtosid(gid_t gid, char **sid, char *buffer,
> - size_t buflen, int *errnop);
>
> int
> netbsdwinbind_endgrent(void *nsrv, void *nscb, va_list ap)
> --
> 1.9.1
>
More information about the samba-technical
mailing list