|
|
841ac7 |
From 921a949f6aa8170f851483e4d5763b3e8fb5d5c9 Mon Sep 17 00:00:00 2001
|
|
|
841ac7 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
841ac7 |
Date: Fri, 22 Mar 2019 14:21:00 +0100
|
|
|
841ac7 |
Subject: [PATCH 13/15] negcache_files: got rid of large array on stack
|
|
|
841ac7 |
|
|
|
841ac7 |
Removed large buffer from function stack.
|
|
|
841ac7 |
It is safe to use single (static) global buffer since:
|
|
|
841ac7 |
1) Responders are single threaded
|
|
|
841ac7 |
2) Code doesn't use content of this buffer anyway
|
|
|
841ac7 |
|
|
|
841ac7 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
841ac7 |
(cherry picked from commit 8e6656c974ac05bb52607014bb4c30b87f4abd8b)
|
|
|
841ac7 |
|
|
|
841ac7 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
841ac7 |
---
|
|
|
841ac7 |
src/responder/common/negcache_files.c | 13 +++++--------
|
|
|
841ac7 |
1 file changed, 5 insertions(+), 8 deletions(-)
|
|
|
841ac7 |
|
|
|
841ac7 |
diff --git a/src/responder/common/negcache_files.c b/src/responder/common/negcache_files.c
|
|
|
841ac7 |
index 85a7065a4..f22796a0c 100644
|
|
|
841ac7 |
--- a/src/responder/common/negcache_files.c
|
|
|
841ac7 |
+++ b/src/responder/common/negcache_files.c
|
|
|
841ac7 |
@@ -24,12 +24,12 @@
|
|
|
841ac7 |
#include "responder/common/negcache_files.h"
|
|
|
841ac7 |
|
|
|
841ac7 |
#define BUFFER_SIZE 16384
|
|
|
841ac7 |
+static char s_nss_buffer[BUFFER_SIZE];
|
|
|
841ac7 |
|
|
|
841ac7 |
bool is_user_local_by_name(const struct sss_nss_ops *ops, const char *name)
|
|
|
841ac7 |
{
|
|
|
841ac7 |
struct passwd pwd = { 0 };
|
|
|
841ac7 |
int errnop;
|
|
|
841ac7 |
- char buffer[BUFFER_SIZE];
|
|
|
841ac7 |
enum nss_status ret;
|
|
|
841ac7 |
char *shortname = NULL;
|
|
|
841ac7 |
int parse_ret;
|
|
|
841ac7 |
@@ -39,7 +39,7 @@ bool is_user_local_by_name(const struct sss_nss_ops *ops, const char *name)
|
|
|
841ac7 |
return false;
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
- ret = ops->getpwnam_r(shortname, &pwd, buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
+ ret = ops->getpwnam_r(shortname, &pwd, s_nss_buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
talloc_free(shortname);
|
|
|
841ac7 |
if (ret == NSS_STATUS_SUCCESS) {
|
|
|
841ac7 |
DEBUG(SSSDBG_TRACE_FUNC, "User %s is a local user\n", name);
|
|
|
841ac7 |
@@ -53,10 +53,9 @@ bool is_user_local_by_uid(const struct sss_nss_ops *ops, uid_t uid)
|
|
|
841ac7 |
{
|
|
|
841ac7 |
struct passwd pwd = { 0 };
|
|
|
841ac7 |
int errnop;
|
|
|
841ac7 |
- char buffer[BUFFER_SIZE];
|
|
|
841ac7 |
enum nss_status ret;
|
|
|
841ac7 |
|
|
|
841ac7 |
- ret = ops->getpwuid_r(uid, &pwd, buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
+ ret = ops->getpwuid_r(uid, &pwd, s_nss_buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
if (ret == NSS_STATUS_SUCCESS) {
|
|
|
841ac7 |
DEBUG(SSSDBG_TRACE_FUNC,
|
|
|
841ac7 |
"User with UID %"SPRIuid" is a local user\n", uid);
|
|
|
841ac7 |
@@ -70,7 +69,6 @@ bool is_group_local_by_name(const struct sss_nss_ops *ops, const char *name)
|
|
|
841ac7 |
{
|
|
|
841ac7 |
struct group grp = { 0 };
|
|
|
841ac7 |
int errnop;
|
|
|
841ac7 |
- char buffer[BUFFER_SIZE];
|
|
|
841ac7 |
enum nss_status ret;
|
|
|
841ac7 |
char *shortname = NULL;
|
|
|
841ac7 |
int parse_ret;
|
|
|
841ac7 |
@@ -80,7 +78,7 @@ bool is_group_local_by_name(const struct sss_nss_ops *ops, const char *name)
|
|
|
841ac7 |
return false;
|
|
|
841ac7 |
}
|
|
|
841ac7 |
|
|
|
841ac7 |
- ret = ops->getgrnam_r(shortname, &grp, buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
+ ret = ops->getgrnam_r(shortname, &grp, s_nss_buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
talloc_free(shortname);
|
|
|
841ac7 |
if (ret == NSS_STATUS_SUCCESS) {
|
|
|
841ac7 |
DEBUG(SSSDBG_TRACE_FUNC, "Group %s is a local group\n", name);
|
|
|
841ac7 |
@@ -94,10 +92,9 @@ bool is_group_local_by_gid(const struct sss_nss_ops *ops, uid_t gid)
|
|
|
841ac7 |
{
|
|
|
841ac7 |
struct group grp = { 0 };
|
|
|
841ac7 |
int errnop;
|
|
|
841ac7 |
- char buffer[BUFFER_SIZE];
|
|
|
841ac7 |
enum nss_status ret;
|
|
|
841ac7 |
|
|
|
841ac7 |
- ret = ops->getgrgid_r(gid, &grp, buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
+ ret = ops->getgrgid_r(gid, &grp, s_nss_buffer, BUFFER_SIZE, &errnop);
|
|
|
841ac7 |
if (ret == NSS_STATUS_SUCCESS) {
|
|
|
841ac7 |
DEBUG(SSSDBG_TRACE_FUNC,
|
|
|
841ac7 |
"Group with GID %"SPRIgid" is a local group\n", gid);
|
|
|
841ac7 |
--
|
|
|
841ac7 |
2.19.1
|
|
|
841ac7 |
|