4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina Pavel Březina <pbrezina@redhat.com>
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina Copyright (C) 2016 Red Hat
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina This program is free software; you can redistribute it and/or modify
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina it under the terms of the GNU General Public License as published by
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina the Free Software Foundation; either version 3 of the License, or
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina (at your option) any later version.
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina This program is distributed in the hope that it will be useful,
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina GNU General Public License for more details.
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina You should have received a copy of the GNU General Public License
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březinanss_protocol_fill_netgr_triple(struct sss_packet *packet,
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina to_sized_string(&host, entry->value.triple.hostname);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina to_sized_string(&user, entry->value.triple.username);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina to_sized_string(&domain, entry->value.triple.domainname);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = sss_packet_grow(packet, sizeof(uint32_t)
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to grow packet!\n");
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina sss_packet_get_body(packet, &body, &body_len);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_UINT32(&body[*_rp], SSS_NETGR_REP_TRIPLE, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_STRING(&body[*_rp], host.str, host.len, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_STRING(&body[*_rp], user.str, user.len, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_STRING(&body[*_rp], domain.str, domain.len, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březinanss_protocol_fill_netgr_member(struct sss_packet *packet,
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina if (entry->value.groupname == NULL || entry->value.groupname[0] == '\0') {
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Empty netgroup member!\n");
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina to_sized_string(&group, entry->value.groupname);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = sss_packet_grow(packet, sizeof(uint32_t) + group.len);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to grow packet!\n");
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina sss_packet_get_body(packet, &body, &body_len);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_UINT32(&body[*_rp], SSS_NETGR_REP_GROUP, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_STRING(&body[*_rp], group.str, group.len, _rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březinanss_protocol_fill_netgrent(struct nss_ctx *nss_ctx,
08db22b1b1a2e742edbca92e35087294d963addaSumit Bose if (idx->result > cmd_ctx->enum_ctx->netgroup_count) {
08db22b1b1a2e742edbca92e35087294d963addaSumit Bose "Unconsistent state while processing netgroups.\n");
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina /* First two fields (length and reserved), filled up later. */
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = sss_packet_grow(packet, 2 * sizeof(uint32_t));
39e300314cb43e534179a6950274e1e9c9a48465Lukas Slebodnik for (; entries[idx->result] != NULL; idx->result++) {
39e300314cb43e534179a6950274e1e9c9a48465Lukas Slebodnik if ((idx->result - start) >= cmd_ctx->enum_limit) {
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina /* We have reached result limit. */
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = nss_protocol_fill_netgr_triple(packet, entry, &rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = nss_protocol_fill_netgr_member(packet, entry, &rp);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unexpected value type!\n");
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina sss_packet_get_body(packet, &body, &body_len);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_COPY_UINT32(body, &num_results, NULL);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SETMEM_UINT32(body + sizeof(uint32_t), 0, NULL); /* reserved */
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březinanss_protocol_fill_setnetgrent(struct nss_ctx *nss_ctx,
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina /* Two fields (length and reserved). */
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina ret = sss_packet_grow(packet, 2 * sizeof(uint32_t));
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina sss_packet_get_body(packet, &body, &body_len);
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SET_UINT32(body, 1, NULL); /* Netgroup was found. */
4049b63f8c67ada17b453463b0451ca6be3d5de4Pavel Březina SAFEALIGN_SETMEM_UINT32(body + sizeof(uint32_t), 0, NULL); /* reserved */