Skip to content

Commit 64ee91f

Browse files
arrowdikerexxe
authored andcommitted
getsockopt: Pass correct option level value on FreeBSD
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com> Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
1 parent b970e7f commit 64ee91f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/responder/common/responder_common.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ static errno_t get_client_cred(struct cli_ctx *cctx)
108108
char cmd_line[255] = { 0 };
109109
int proc_fd;
110110

111-
ret = getsockopt(cctx->cfd, SOL_SOCKET, SSS_PEERCRED_SOCKET_OPTION, &cctx->creds->ucred,
111+
ret = getsockopt(cctx->cfd, SSS_PEERCRED_OPTION_LEVEL,
112+
SSS_PEERCRED_SOCKET_OPTION, &cctx->creds->ucred,
112113
&client_cred_len);
113114
if (ret != EOK) {
114115
talloc_zfree(cctx->creds);

src/shared/cred.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
#ifdef HAVE_UCRED
2929

3030
#include <sys/socket.h>
31-
#define SSS_PEERCRED_SOCKET_OPTION SO_PEERCRED
3231
#define STRUCT_CRED struct ucred
32+
#define SSS_PEERCRED_OPTION_LEVEL SOL_SOCKET
33+
#define SSS_PEERCRED_SOCKET_OPTION SO_PEERCRED
3334
#define CRED_UID(x) ((x)->uid)
3435
#define CRED_GID(x) ((x)->gid)
3536
#define CRED_PID(x) ((x)->pid)
@@ -46,6 +47,7 @@
4647
*/
4748
#include <sys/ucred.h>
4849
#define STRUCT_CRED struct xucred
50+
#define SSS_PEERCRED_OPTION_LEVEL SOL_LOCAL
4951
#define SSS_PEERCRED_SOCKET_OPTION LOCAL_PEERCRED
5052
#define CRED_UID(x) ((x)->cr_uid)
5153
#define CRED_GID(x) ((x)->cr_ngroups > 0 ? (x)->cr_groups[0] : -1)

src/sss_client/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,8 @@ static errno_t check_server_cred(int sockfd)
10341034
return EFAULT;
10351035
}
10361036

1037-
ret = getsockopt(sockfd, SOL_SOCKET, SSS_PEERCRED_SOCKET_OPTION, &server_cred,
1038-
&server_cred_len);
1037+
ret = getsockopt(sockfd, SSS_PEERCRED_OPTION_LEVEL, SSS_PEERCRED_SOCKET_OPTION,
1038+
&server_cred, &server_cred_len);
10391039
if (ret != 0) {
10401040
return errno;
10411041
}

0 commit comments

Comments
 (0)