summaryrefslogtreecommitdiff
path: root/server/responder/common
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2009-08-14 13:51:19 -0400
committerSimo Sorce <ssorce@redhat.com>2009-08-27 09:35:54 -0400
commitda8895b8db42353fed02c4fac25d5aa155d4b291 (patch)
tree78f710be626ec3848a473d0aeda7a1e476f69d6e /server/responder/common
parent3a87621a3eeb76ce6ac3b18877874141c2dc102e (diff)
downloadsssd-da8895b8db42353fed02c4fac25d5aa155d4b291.tar.gz
sssd-da8895b8db42353fed02c4fac25d5aa155d4b291.tar.bz2
sssd-da8895b8db42353fed02c4fac25d5aa155d4b291.zip
Fix group replies when using member/memberof
Also remove legacy memberuid support
Diffstat (limited to 'server/responder/common')
-rw-r--r--server/responder/common/responder_packet.c45
-rw-r--r--server/responder/common/responder_packet.h2
2 files changed, 41 insertions, 6 deletions
diff --git a/server/responder/common/responder_packet.c b/server/responder/common/responder_packet.c
index 24762934..6e581a3c 100644
--- a/server/responder/common/responder_packet.c
+++ b/server/responder/common/responder_packet.c
@@ -119,12 +119,16 @@ int sss_packet_grow(struct sss_packet *packet, size_t size)
}
packet->memsize = totlen;
- packet->buffer = newmem;
- packet->len = &((uint32_t *)packet->buffer)[0];
- packet->cmd = &((uint32_t *)packet->buffer)[1];
- packet->status = &((uint32_t *)packet->buffer)[2];
- packet->reserved = &((uint32_t *)packet->buffer)[3];
- packet->body = (uint8_t *)&((uint32_t *)packet->buffer)[4];
+
+ /* re-set pointers if realloc had to move memory */
+ if (newmem != packet->buffer) {
+ packet->buffer = newmem;
+ packet->len = &((uint32_t *)packet->buffer)[0];
+ packet->cmd = &((uint32_t *)packet->buffer)[1];
+ packet->status = &((uint32_t *)packet->buffer)[2];
+ packet->reserved = &((uint32_t *)packet->buffer)[3];
+ packet->body = (uint8_t *)&((uint32_t *)packet->buffer)[4];
+ }
}
*(packet->len) += size;
@@ -132,6 +136,35 @@ int sss_packet_grow(struct sss_packet *packet, size_t size)
return 0;
}
+/* reclaim backet previously resrved space in the packet
+ * usually done in functione recovering from not fatal erros */
+int sss_packet_shrink(struct sss_packet *packet, size_t size)
+{
+ size_t newlen;
+
+ if (size > *(packet->len)) return EINVAL;
+
+ newlen = *(packet->len) - size;
+ if (newlen < SSS_NSS_HEADER_SIZE) return EINVAL;
+
+ *(packet->len) = newlen;
+ return 0;
+}
+
+int sss_packet_set_size(struct sss_packet *packet, size_t size)
+{
+ size_t newlen;
+
+ newlen = SSS_NSS_HEADER_SIZE + size;
+
+ /* make sure we do not overflow */
+ if (packet->memsize < newlen) return EINVAL;
+
+ *(packet->len) = newlen;
+
+ return 0;
+}
+
int sss_packet_recv(struct sss_packet *packet, int fd)
{
size_t rb;
diff --git a/server/responder/common/responder_packet.h b/server/responder/common/responder_packet.h
index 5dc8b016..e98707a6 100644
--- a/server/responder/common/responder_packet.h
+++ b/server/responder/common/responder_packet.h
@@ -32,6 +32,8 @@ int sss_packet_new(TALLOC_CTX *mem_ctx, size_t size,
enum sss_cli_command cmd,
struct sss_packet **rpacket);
int sss_packet_grow(struct sss_packet *packet, size_t size);
+int sss_packet_shrink(struct sss_packet *packet, size_t size);
+int sss_packet_set_size(struct sss_packet *packet, size_t size);
int sss_packet_recv(struct sss_packet *packet, int fd);
int sss_packet_send(struct sss_packet *packet, int fd);
enum sss_cli_command sss_packet_get_cmd(struct sss_packet *packet);