diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-03-10 01:59:13 -0400 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-03-10 02:08:39 -0400 |
commit | d0e33c2a035c4c877b9f624b6999899666cb6385 (patch) | |
tree | 427598b7f636fc826b4b7d5983e1e8acc2bb28f4 | |
parent | 16187da9bae78b6f4dd4ea21faf49fccc821f153 (diff) | |
download | sssd-d0e33c2a035c4c877b9f624b6999899666cb6385.tar.gz sssd-d0e33c2a035c4c877b9f624b6999899666cb6385.tar.bz2 sssd-d0e33c2a035c4c877b9f624b6999899666cb6385.zip |
Treat uids and gids as 32 bit numbers not 64
In the nss communication protocol we were treating uids and gids as 64 bit
values, but uids and gids are really u32 values, change the protocol to reflect
the real size.
-rw-r--r-- | server/responder/nss/nsssrv_cmd.c | 44 | ||||
-rw-r--r-- | sss_client/group.c | 32 | ||||
-rw-r--r-- | sss_client/passwd.c | 22 | ||||
-rw-r--r-- | sss_client/sss_cli.h | 2 |
4 files changed, 49 insertions, 51 deletions
diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index e9fbda63..f55a177b 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -30,7 +30,7 @@ struct nss_cmd_ctx { struct cli_ctx *cctx; const char *name; - uid_t id; + uint32_t id; bool immediate; bool done; @@ -189,8 +189,8 @@ static int fill_pwent(struct sss_packet *packet, const char *fullname; const char *homedir; const char *shell; - uint64_t uid; - uint64_t gid; + uint32_t uid; + uint32_t gid; size_t rsize, rp, blen; size_t s1, s2, s3, s4; size_t dom_len = 0; @@ -223,7 +223,7 @@ static int fill_pwent(struct sss_packet *packet, s2 = strlen(fullname) + 1; s3 = strlen(homedir) + 1; s4 = strlen(shell) + 1; - rsize = 2*sizeof(uint64_t) +s1 + 2 + s2 + s3 +s4; + rsize = 2*sizeof(uint32_t) +s1 + 2 + s2 + s3 +s4; if (add_domain) rsize += dom_len; ret = sss_packet_grow(packet, rsize); @@ -233,9 +233,9 @@ static int fill_pwent(struct sss_packet *packet, } sss_packet_get_body(packet, &body, &blen); - ((uint64_t *)(&body[rp]))[0] = uid; - ((uint64_t *)(&body[rp]))[1] = gid; - rp += 2*sizeof(uint64_t); + ((uint32_t *)(&body[rp]))[0] = uid; + ((uint32_t *)(&body[rp]))[1] = gid; + rp += 2*sizeof(uint32_t); memcpy(&body[rp], name, s1); rp += s1; if (add_domain) { @@ -656,11 +656,11 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx) /* get uid to query */ sss_packet_get_body(cctx->creq->in, &body, &blen); - if (blen != sizeof(uint64_t)) { + if (blen != sizeof(uint32_t)) { return EINVAL; } - cmdctx->id = (uid_t)*((uint64_t *)body); + cmdctx->id = *((uint32_t *)body); /* FIXME: Just ask all backends for now, until we check for ranges */ dctx = NULL; @@ -1061,7 +1061,7 @@ static int fill_grent(struct sss_packet *packet, struct ldb_message *msg; uint8_t *body; const char *name; - uint64_t gid; + uint32_t gid; size_t rsize, rp, blen, mnump; int i, j, ret, num, memnum; bool get_members; @@ -1102,23 +1102,23 @@ static int fill_grent(struct sss_packet *packet, /* fill in gid and name and set pointer for number of members */ name_len = strlen(name)+1; - rsize = sizeof(uint64_t) + sizeof(uint32_t) + name_len +2; + rsize = 2 * sizeof(uint32_t) + name_len +2; if (add_domain) rsize += dom_len; ret = sss_packet_grow(packet, rsize); sss_packet_get_body(packet, &body, &blen); - /* 0-7: 64bit number gid */ + /* 0-3: 64bit number gid */ rp = blen - rsize; - ((uint64_t *)(&body[rp]))[0] = gid; - rp += sizeof(uint64_t); + ((uint32_t *)(&body[rp]))[0] = gid; + rp += sizeof(uint32_t); - /* 8-11: 32bit unsigned number of members */ + /* 4-7: 32bit unsigned number of members */ ((uint32_t *)(&body[rp]))[0] = 0; /* init members num to 0 */ mnump = rp; /* keep around members num pointer to set later */ rp += sizeof(uint32_t); - /* 12-X: sequence of strings (name, passwd, mem..) */ + /* 8-X: sequence of strings (name, passwd, mem..) */ memcpy(&body[rp], name, name_len); rp += name_len; if (add_domain) { @@ -1593,11 +1593,11 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx) /* get uid to query */ sss_packet_get_body(cctx->creq->in, &body, &blen); - if (blen != sizeof(uint64_t)) { + if (blen != sizeof(uint32_t)) { return EINVAL; } - cmdctx->id = (gid_t)*((uint64_t *)body); + cmdctx->id = *((uint32_t *)body); /* FIXME: Just ask all backends for now, until we check for ranges */ dctx = NULL; @@ -1991,7 +1991,7 @@ static void nss_cmd_initgr_callback(void *ptr, int status, struct cli_ctx *cctx = cmdctx->cctx; uint8_t *body; size_t blen; - uint64_t gid; + uint32_t gid; uint32_t num; int ret, i; @@ -2009,9 +2009,7 @@ static void nss_cmd_initgr_callback(void *ptr, int status, } num = res->count; - /* the first 64 bit uint is really 2 32 units used to hold the number of - * results */ - ret = sss_packet_grow(cctx->creq->out, (1 + num) * sizeof(uint64_t)); + ret = sss_packet_grow(cctx->creq->out, (2 + num) * sizeof(uint32_t)); if (ret != EOK) { sss_packet_set_error(cctx->creq->out, ret); goto done; @@ -2026,7 +2024,7 @@ static void nss_cmd_initgr_callback(void *ptr, int status, num = 0; goto done; } - ((uint64_t *)body)[i+1] = gid; + ((uint32_t *)body)[2+i] = gid; } ((uint32_t *)body)[0] = num; /* num results */ diff --git a/sss_client/group.c b/sss_client/group.c index 66cec623..4ba11e30 100644 --- a/sss_client/group.c +++ b/sss_client/group.c @@ -51,21 +51,21 @@ static void sss_nss_getgrent_data_clean(void) { * * GERTGRGID Request: * - * 0-7: 64bit number with gid + * 0-7: 32bit number with gid * * INITGROUPS Request: * - * 0-7: 64bit number with gid - * 8-11: 32bit unsigned with max num of entries + * 0-3: 32bit number with gid + * 4-7: 32bit unsigned with max num of entries * * Replies: * * 0-3: 32bit unsigned number of results * 4-7: 32bit unsigned (reserved/padding) * For each result (64bit padded ?): - * 0-7: 64bit number gid - * 8-11: 32bit unsigned number of members - * 12-X: sequence of 0 terminated strings (name, passwd, mem..) + * 0-3: 32bit number gid + * 4-7: 32bit unsigned number of members + * 8-X: sequence of 0 terminated strings (name, passwd, mem..) */ struct sss_nss_gr_rep { struct group *result; @@ -82,15 +82,15 @@ static int sss_nss_getgr_readrep(struct sss_nss_gr_rep *pr, uint32_t mem_num; int err; - if (*len < 15) { /* not enough space for data, bad packet */ + if (*len < 11) { /* not enough space for data, bad packet */ return EBADMSG; } - pr->result->gr_gid = ((uint64_t *)buf)[0]; - mem_num = ((uint32_t *)buf)[2]; + pr->result->gr_gid = ((uint32_t *)buf)[0]; + mem_num = ((uint32_t *)buf)[1]; - sbuf = (char *)&buf[12]; - slen = *len - 12; + sbuf = (char *)&buf[8]; + slen = *len - 8; dlen = pr->buflen; pr->result->gr_name = &(pr->buffer[0]); @@ -165,7 +165,7 @@ static int sss_nss_getgr_readrep(struct sss_nss_gr_rep *pr, * 0-3: 32bit unsigned number of results * 4-7: 32bit unsigned (reserved/padding) * For each result: - * 0-7: 64bit number with gid + * 0-4: 32bit number with gid */ @@ -178,7 +178,7 @@ enum nss_status _nss_sss_initgroups_dyn(const char *user, gid_t group, uint8_t *repbuf; size_t replen; enum nss_status nret; - uint64_t *rbuf; + uint32_t *rbuf; uint32_t num_ret; long int l, max_ret; @@ -220,7 +220,7 @@ enum nss_status _nss_sss_initgroups_dyn(const char *user, gid_t group, *size = newsize; } - rbuf = &((uint64_t *)repbuf)[1]; + rbuf = &((uint32_t *)repbuf)[2]; for (l = 0; l < max_ret; l++) { (*groups)[*start] = rbuf[l]; *start += 1; @@ -284,11 +284,11 @@ enum nss_status _nss_sss_getgrgid_r(gid_t gid, struct group *result, uint8_t *repbuf; size_t replen, len; enum nss_status nret; - uint64_t group_gid; + uint32_t group_gid; int ret; group_gid = gid; - rd.len = sizeof(uint64_t); + rd.len = sizeof(uint32_t); rd.data = &group_gid; nret = sss_nss_make_request(SSS_NSS_GETGRGID, &rd, diff --git a/sss_client/passwd.c b/sss_client/passwd.c index d02e067f..a2ffcad6 100644 --- a/sss_client/passwd.c +++ b/sss_client/passwd.c @@ -51,16 +51,16 @@ static void sss_nss_getpwent_data_clean(void) { * * GERTPWUID Request: * - * 0-7: 64bit number with uid + * 0-3: 32bit number with uid * * Replies: * * 0-3: 32bit unsigned number of results * 4-7: 32bit unsigned (reserved/padding) * For each result: - * 0-7: 64bit number uid - * 8-15: 64bit number gid - * 16-X: sequence of 5, 0 terminated, strings (name, passwd, gecos, dir, shell) + * 0-3: 32bit number uid + * 4-7: 32bit number gid + * 8-X: sequence of 5, 0 terminated, strings (name, passwd, gecos, dir, shell) */ struct sss_nss_pw_rep { @@ -76,14 +76,14 @@ static int sss_nss_getpw_readrep(struct sss_nss_pw_rep *pr, char *sbuf; int err; - if (*len < 21) { /* not enough space for data, bad packet */ + if (*len < 13) { /* not enough space for data, bad packet */ return EBADMSG; } - pr->result->pw_uid = ((int64_t *)buf)[0]; - pr->result->pw_gid = ((int64_t *)buf)[1]; + pr->result->pw_uid = ((uint32_t *)buf)[0]; + pr->result->pw_gid = ((uint32_t *)buf)[1]; - sbuf = (char *)&buf[16]; + sbuf = (char *)&buf[8]; if (*len < pr->buflen) { slen = *len; err = EBADMSG; @@ -147,7 +147,7 @@ static int sss_nss_getpw_readrep(struct sss_nss_pw_rep *pr, return err; } - *len = *len -16 -i -1; + *len = *len -8 -i -1; return 0; } @@ -206,11 +206,11 @@ enum nss_status _nss_sss_getpwuid_r(uid_t uid, struct passwd *result, uint8_t *repbuf; size_t replen, len; enum nss_status nret; - int64_t user_uid; + uint32_t user_uid; int ret; user_uid = uid; - rd.len = sizeof(int64_t); + rd.len = sizeof(uint32_t); rd.data = &user_uid; nret = sss_nss_make_request(SSS_NSS_GETPWUID, &rd, diff --git a/sss_client/sss_cli.h b/sss_client/sss_cli.h index 1e19e5e2..dfb6380c 100644 --- a/sss_client/sss_cli.h +++ b/sss_client/sss_cli.h @@ -21,7 +21,7 @@ #define SSS_PAM_SOCKET_NAME "/var/lib/sss/pipes/pam" #define SSS_PAM_PRIV_SOCKET_NAME "/var/lib/sss/pipes/private/pam" -#define SSS_PROTOCOL_VERSION 0 +#define SSS_PROTOCOL_VERSION 1 enum sss_cli_command { /* null */ |