ipsec and getpeercon()
I'm trying to use getpeercon() with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:
[root@rawhide-clone ~]# runcon -t passwd_t ./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255
[root@rawhide-clone ~]# runcon -t initrc_t ./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255
the process connecting is unconfined_t
Am I doing something wrong or is something broken?
if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr,
&sin_size)) == -1) {
perror("accept");
continue;
}
if (getpeercon(new_fd, con))
perror("getpeercon");
} printf("server: got connection from %s, %s\n",
inet_ntoa(their_addr.sin_addr), con);
I also tried getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 23 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255the process connecting is
unconfined_tAm I doing something wrong or is something broken?
if ((
new_fd= accept(sockfd, (struct sockaddr *)&their_addr,&sin_size)) == -1) { perror("accept"); continue; } if (getpeercon(new_fd, con)) perror("getpeercon"); }
Quoted 6 lines
printf("server: got connection from %s, %s\n",
inet_ntoa(their_addr.sin_addr), con);I also tried
getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)
It also doesn't work at all on the client side:
[root@rawhide ~]# ./client 10.1.13.90
getpeercon: Protocol not available
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 29 lines · Joshua Brindle
Quoted 27 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255the process connecting is
unconfined_tAm I doing something wrong or is something broken?
if ((
new_fd= accept(sockfd, (struct sockaddr *)&their_addr,&sin_size)) == -1) { perror("accept"); continue; } if (getpeercon(new_fd, con)) perror("getpeercon"); } printf("server: got connection from %s, %s\n", inet_ntoa(their_addr.sin_addr), con);
Quoted 9 lines
Quoted 2 lines
I also tried
getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)It also doesn't work at all on the client side:
[root@rawhide ~]# ./client 10.1.13.90
getpeercon: Protocol not available
I realize they are probably pretty simple, but do you have the sources of your test programs posted anywhere?
Signature · 7 lines
paul moore linux security @ hp -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:
This may not help you, but I did a quick test using both the current rawhide kernel as well as David Miller's net-2.6.19 git tree (with the patchset I posted earlier applied) using NetLabel/CIPSO and everything worked as expected, i.e. the MLS label of the context was correct.
Quoted 24 lines
[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255the process connecting is
unconfined_tAm I doing something wrong or is something broken?
if ((
new_fd= accept(sockfd, (struct sockaddr *)&their_addr,&sin_size)) == -1) { perror("accept"); continue; } if (getpeercon(new_fd, con)) perror("getpeercon"); }printf("server: got connection from %s, %s\n",
inet_ntoa(their_addr.sin_addr), con);I also tried
getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)
Signature · 7 lines
paul moore linux security @ hp -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 8 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255
Quoted 6 lines
[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255the process connecting is
unconfined_tAm I doing something wrong or is something broken?
You didn't provide much information above. Kernel version? ipsec-tools version? racoon version? ipsec configuration? setkey -D output? setkey -DP output?
Quoted 14 lines
if ((
new_fd= accept(sockfd, (struct sockaddr *)&their_addr,&sin_size)) == -1) { perror("accept"); continue; } if (getpeercon(new_fd, con)) perror("getpeercon"); }printf("server: got connection from %s, %s\n",
inet_ntoa(their_addr.sin_addr), con);I also tried
getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255
Quoted 7 lines
Quoted 3 lines
the process connecting is
unconfined_tAm I doing something wrong or is something broken?
You didn't provide much information above. Kernel version? ipsec-tools version? racoon version? ipsec configuration? setkey -D output? setkey -DP output?
Sorry,
Linux rawhide-clone 2.6.17-1.2586.fc6 #1 SMP Thu Aug 24 08:51:22 EDT 2006 i686 i686 i386 GNU/Linux
ipsec-tools.i386 0.6.5-3.1
[root@rawhide-clone ~]# setkey -D
10.1.13.104 10.1.13.90
esp mode=transport spi=43920387(0x029e2c03) reqid=0(0x00000000)
E: 3des-cbc ed1dd172 479fc39e 699c619d d626a652 9489f426
12bec67e
A: hmac-sha1 6917f1a2 30a207f8 a1680143 5d490f66 431fd11d
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=3 pid=10324 refcnt=0
10.1.13.104 10.1.13.90
ah mode=transport spi=232904746(0x0de1d82a) reqid=0(0x00000000)
A: hmac-sha1 d0cb6f60 9f4ce933 adcee87f 7ff92c05 f850eb35
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=2 pid=10324 refcnt=0
10.1.13.90 10.1.13.104
esp mode=transport spi=161190146(0x099b9102) reqid=0(0x00000000)
E: 3des-cbc 0a57f388 64520697 db36d889 f0933005 78ec7d6d
a7d2fd42
A: hmac-sha1 372a4cec 3035f96f fa3e3e33 85e16efb 85d88ba7
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:35 2006 current: Aug 15 11:50:10 2006
diff: 2795(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=1 pid=10324 refcnt=0
10.1.13.90 10.1.13.104
ah mode=transport spi=135759512(0x08178698) reqid=0(0x00000000)
A: hmac-sha1 fcccf815 4ba32275 78731b59 20659361 6f7ddf81
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=0 pid=10324 refcnt=0[root@rawhide-clone ~]# setkey -D
10.1.13.104 10.1.13.90
esp mode=transport spi=43920387(0x029e2c03) reqid=0(0x00000000)
E: 3des-cbc ed1dd172 479fc39e 699c619d d626a652 9489f426
12bec67e
A: hmac-sha1 6917f1a2 30a207f8 a1680143 5d490f66 431fd11d
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=3 pid=10324 refcnt=0
10.1.13.104 10.1.13.90
ah mode=transport spi=232904746(0x0de1d82a) reqid=0(0x00000000)
A: hmac-sha1 d0cb6f60 9f4ce933 adcee87f 7ff92c05 f850eb35
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=2 pid=10324 refcnt=0
10.1.13.90 10.1.13.104
esp mode=transport spi=161190146(0x099b9102) reqid=0(0x00000000)
E: 3des-cbc 0a57f388 64520697 db36d889 f0933005 78ec7d6d
a7d2fd42
A: hmac-sha1 372a4cec 3035f96f fa3e3e33 85e16efb 85d88ba7
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:35 2006 current: Aug 15 11:50:10 2006
diff: 2795(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=1 pid=10324 refcnt=0
10.1.13.90 10.1.13.104
ah mode=transport spi=135759512(0x08178698) reqid=0(0x00000000)
A: hmac-sha1 fcccf815 4ba32275 78731b59 20659361 6f7ddf81
seq=0x00000000 replay=4 flags=0x00000000 state=mature
created: Aug 15 11:03:34 2006 current: Aug 15 11:50:10 2006
diff: 2796(s) hard: 3600(s) soft: 2880(s)
last: hard: 0(s) soft: 0(s)
current: 0(bytes) hard: 0(bytes) soft: 0(bytes)
allocated: 0 hard: 0 soft: 0
sadb_seq=0 pid=10324 refcnt=0Quoted 14 lines
Quoted 14 lines
if ((
new_fd= accept(sockfd, (struct sockaddr *)&their_addr,&sin_size)) == -1) { perror("accept"); continue; } if (getpeercon(new_fd, con)) perror("getpeercon"); }printf("server: got connection from %s, %s\n",
inet_ntoa(their_addr.sin_addr), con);
Quoted 2 lines
Quoted 1 line
I also tried
getsockopt(new_fd, SOL_SOCKET, SO_PEERSEC, con, &len)
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 29 lines · Joshua Brindle
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255Quoted 7 lines
Quoted 3 lines
the process connecting is
unconfined_tAm I doing something wrong or is something broken?
You didn't provide much information above. Kernel version? ipsec-tools version? racoon version? ipsec configuration? setkey -D output? setkey -DP output?
Sorry,
Linux rawhide-clone 2.6.17-1.2586.fc6 #1 SMP Thu Aug 24 08:51:22 EDT 2006 i686 i686 i386 GNU/Linux
ipsec-tools.i386 0.6.5-3.1
[root@rawhide-clone ~]# setkey -D
<snip>
Quoted 1 line
[root@rawhide-clone ~]# setkey -D
One of those was supposed to be a setkey -DP.
You did remember to specify a -ctx option when you added spd entries, right?
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 29 lines · Stephen Smalley
Quoted 28 lines · Joshua Brindle
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255Quoted 7 lines
Quoted 3 lines
the process connecting is
unconfined_tAm I doing something wrong or is something broken?
You didn't provide much information above. Kernel version? ipsec-tools version? racoon version? ipsec configuration? setkey -D output? setkey -DP output?
Sorry,
Linux rawhide-clone 2.6.17-1.2586.fc6 #1 SMP Thu Aug 24 08:51:22 EDT 2006 i686 i686 i386 GNU/Linux
ipsec-tools.i386 0.6.5-3.1
Quoted 8 lines
Quoted 1 line
[root@rawhide-clone ~]# setkey -D
<snip>
Quoted 1 line
[root@rawhide-clone ~]# setkey -D
One of those was supposed to be a setkey -DP.
You did remember to specify a -ctx option when you added spd entries, right?
BTW, Joy & Venkat - it would be nice if the usage/configuration of the ipsec labeling was documented somewhere. I've seen emails in the past with sample usage, but has it been captured anywhere we can refer people to, like in the Fedora SELinux wiki?
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · Stephen Smalley
BTW, Joy & Venkat - it would be nice if the usage/configuration of the ipsec labeling was documented somewhere. I've seen emails in the past with sample usage, but has it been captured anywhere we can refer people to, like in the Fedora SELinux wiki?
I have the impression that the Fedora SELinux wiki isn't being updated anymore since it's not editable without jumping through hoops that seem excessive even to people working on a MLS/RBAC system...
-Klaus
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 9 lines · Klaus Weidner
Quoted 4 lines · Stephen Smalley
BTW, Joy & Venkat - it would be nice if the usage/configuration of the ipsec labeling was documented somewhere. I've seen emails in the past with sample usage, but has it been captured anywhere we can refer people to, like in the Fedora SELinux wiki?
I have the impression that the Fedora SELinux wiki isn't being updated anymore since it's not editable without jumping through hoops that seem excessive even to people working on a MLS/RBAC system...
I see. Well, if someone would like to add documentation to the sourceforge selinux project, I can add access for people known to me. Not a wiki, but hopefully not too cumbersome to use as a place to upload documents.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 27 lines · Stephen Smalley
Quoted 26 lines · Joshua Brindle
Quoted 12 lines · Stephen Smalley
Quoted 11 lines · Joshua Brindle
I'm trying to use
getpeercon()with a tcp stream socket over an ipsec host2host connection and it isn't working, it always returns the context of the local domain/socket:[root@rawhide-clone ~]# runcon -t
passwd_t./server
server: got connection from 10.1.13.104, root:system_r:passwd_t:s0-s0:c0.c255[root@rawhide-clone ~]# runcon -t
initrc_t./server
server: got connection from 10.1.13.104, root:system_r:initrc_t:s0-s0:c0.c255Quoted 7 lines
Quoted 3 lines
the process connecting is
unconfined_tAm I doing something wrong or is something broken?
You didn't provide much information above. Kernel version? ipsec-tools version? racoon version? ipsec configuration? setkey -D output? setkey -DP output?
Sorry,
Linux rawhide-clone 2.6.17-1.2586.fc6 #1 SMP Thu Aug 24 08:51:22 EDT 2006 i686 i686 i386 GNU/Linux
Quoted 8 lines
Quoted 3 lines
ipsec-tools.i386 0.6.5-3.1
[root@rawhide-clone ~]# setkey -D
<snip>
Quoted 1 line
[root@rawhide-clone ~]# setkey -D
One of those was supposed to be a setkey -DP.
err, yea, i mispasted
[root@joker-rawhide-clone ~]# setkey -DP
10.1.13.104[any] 10.1.13.90[any] any
in prio def ipsec
esp/transport//require
ah/transport//require
created: Aug 15 08:25:20 2006 lastused: Aug 15 10:15:35 2006
lifetime: 0(s) validtime: 0(s)
spid=1192 seq=10 pid=10325
refcnt=1
10.1.13.90[any] 10.1.13.104[any] any
out prio def ipsec
esp/transport//require
ah/transport//require
created: Aug 15 08:25:20 2006 lastused: Aug 15 10:15:35 2006
lifetime: 0(s) validtime: 0(s)
spid=1185 seq=9 pid=10325
refcnt=1
10.1.13.104[any] 10.1.13.90[any] any
fwd prio def ipsec
esp/transport//require
ah/transport//require
created: Aug 15 08:25:20 2006 lastused:
lifetime: 0(s) validtime: 0(s)
spid=1202 seq=8 pid=10325
refcnt=1
(per-socket policy)
in none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1259 seq=7 pid=10325
refcnt=1
(per-socket policy)
in none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1243 seq=6 pid=10325
refcnt=1
(per-socket policy)
in none
created: Aug 15 08:25:21 2006 lastused: Aug 15 11:03:34 2006
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1227 seq=5 pid=10325
refcnt=1
(per-socket policy)
in none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1211 seq=4 pid=10325
refcnt=1
(per-socket policy)
out none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1268 seq=3 pid=10325
refcnt=1
(per-socket policy)
out none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1252 seq=2 pid=10325
refcnt=1
(per-socket policy)
out none
created: Aug 15 08:25:21 2006 lastused: Aug 15 11:03:34 2006
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1236 seq=1 pid=10325
refcnt=1
(per-socket policy)
out none
created: Aug 15 08:25:21 2006 lastused:
lifetime: 0(s) validtime: 0(s)
security context doi: 1
security context algorithm: 1
security context length: 41
security context: root:system_r:unconfined_t:s0-s0:c0.c255
spid=1220 seq=0 pid=10325
refcnt=1Quoted 3 lines
You did remember to specify a -ctx option when you added spd entries, right?
I didn't add anything, I used system-config-network :) I'm pretty new to ipsec actually so that was the only thing I could find on doing this in Fedora. I found nothing on the selinux parts
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.