mirror of
https://git.yoctoproject.org/meta-security
synced 2026-01-11 15:00:34 +00:00
meta-security: Convert to new override syntax
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
@@ -29,7 +29,7 @@ S = "${WORKDIR}/git"
|
||||
|
||||
PARALLEL_MAKE = ""
|
||||
|
||||
COMPATIBLE_MACHINE_mips64 = "(!.*mips64).*"
|
||||
COMPATIBLE_MACHINE:mips64 = "(!.*mips64).*"
|
||||
|
||||
inherit pkgconfig autotools-brokensep update-rc.d python3native python3targetconfig perlnative cpan systemd features_check bash-completion
|
||||
|
||||
@@ -106,11 +106,11 @@ do_install () {
|
||||
}
|
||||
|
||||
#Building ptest on arm fails.
|
||||
do_compile_ptest_aarch64 () {
|
||||
do_compile_ptest:aarch64 () {
|
||||
:
|
||||
}
|
||||
|
||||
do_compile_ptest_arm () {
|
||||
do_compile_ptest:arm () {
|
||||
:
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@ do_install_ptest () {
|
||||
}
|
||||
|
||||
#Building ptest on arm fails.
|
||||
do_install_ptest_aarch64 () {
|
||||
do_install_ptest:aarch64 () {
|
||||
:
|
||||
}
|
||||
|
||||
do_install_ptest_arm() {
|
||||
do_install_ptest:arm() {
|
||||
:
|
||||
}
|
||||
|
||||
@@ -153,23 +153,23 @@ INITSCRIPT_NAME = "apparmor"
|
||||
INITSCRIPT_PARAMS = "start 16 2 3 4 5 . stop 35 0 1 6 ."
|
||||
|
||||
SYSTEMD_PACKAGES = "${PN}"
|
||||
SYSTEMD_SERVICE_${PN} = "apparmor.service"
|
||||
SYSTEMD_SERVICE:${PN} = "apparmor.service"
|
||||
SYSTEMD_AUTO_ENABLE ?= "enable"
|
||||
|
||||
PACKAGES += "mod-${PN}"
|
||||
|
||||
FILES_${PN} += "${nonarch_base_libdir}/apparmor/ ${base_libdir}/security/ ${sysconfdir}/apparmor ${nonarch_libdir}/${PYTHON_DIR}/site-packages"
|
||||
FILES_mod-${PN} = "${libdir}/apache2/modules/*"
|
||||
FILES_${PN}-dbg += "${base_libdir}/security/.debug"
|
||||
FILES:${PN} += "${nonarch_base_libdir}/apparmor/ ${base_libdir}/security/ ${sysconfdir}/apparmor ${nonarch_libdir}/${PYTHON_DIR}/site-packages"
|
||||
FILES:mod-${PN} = "${libdir}/apache2/modules/*"
|
||||
FILES:${PN}-dbg += "${base_libdir}/security/.debug"
|
||||
|
||||
DEPENDS_append_libc-musl = " fts "
|
||||
RDEPENDS_${PN}_libc-musl += "musl-utils"
|
||||
RDEPENDS_${PN}_libc-glibc += "glibc-utils"
|
||||
DEPENDS:append:libc-musl = " fts "
|
||||
RDEPENDS:${PN}:libc-musl += "musl-utils"
|
||||
RDEPENDS:${PN}:libc-glibc += "glibc-utils"
|
||||
|
||||
# Add coreutils and findutils only if sysvinit scripts are in use
|
||||
RDEPENDS_${PN} += "${@["coreutils findutils", ""][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd')]} ${@bb.utils.contains('PACKAGECONFIG','python','python3-core python3-modules','', d)}"
|
||||
RDEPENDS_${PN}_remove += "${@bb.utils.contains('PACKAGECONFIG','perl','','perl', d)}"
|
||||
RDEPENDS_${PN}-ptest += "perl coreutils dbus-lib bash"
|
||||
RDEPENDS:${PN} += "${@["coreutils findutils", ""][(d.getVar('VIRTUAL-RUNTIME_init_manager') == 'systemd')]} ${@bb.utils.contains('PACKAGECONFIG','python','python3-core python3-modules','', d)}"
|
||||
RDEPENDS:${PN}:remove += "${@bb.utils.contains('PACKAGECONFIG','perl','','perl', d)}"
|
||||
RDEPENDS:${PN}-ptest += "perl coreutils dbus-lib bash"
|
||||
|
||||
INSANE_SKIP_${PN} = "ldflags"
|
||||
PRIVATE_LIBS_${PN}-ptest = "libapparmor.so*"
|
||||
INSANE_SKIP:${PN} = "ldflags"
|
||||
PRIVATE_LIBS:${PN}-ptest = "libapparmor.so*"
|
||||
|
||||
@@ -9,4 +9,4 @@ To start via command line add:
|
||||
To initialize:
|
||||
/usr/lib/ccs/init_policy
|
||||
|
||||
DISTRO_FEATURES_append = " tomoyo"
|
||||
DISTRO_FEATURES:append = " tomoyo"
|
||||
|
||||
@@ -29,17 +29,17 @@ do_install(){
|
||||
|
||||
PACKAGE="${PN} ${PN}-dbg ${PN}-doc"
|
||||
|
||||
FILES_${PN} = "\
|
||||
FILES:${PN} = "\
|
||||
${sbindir}/* \
|
||||
${base_sbindir}/* \
|
||||
${libdir}/* \
|
||||
"
|
||||
|
||||
FILES_${PN}-doc = "\
|
||||
FILES:${PN}-doc = "\
|
||||
${mandir}/man8/* \
|
||||
"
|
||||
|
||||
FILES_${PN}-dbg = "\
|
||||
FILES:${PN}-dbg = "\
|
||||
${base_sbindir}/.debug/* \
|
||||
${sbindir}/.debug/* \
|
||||
${libdir}/.debug/* \
|
||||
|
||||
@@ -22,4 +22,4 @@ do_install() {
|
||||
install -m 0755 *.sh ${D}${sbindir}
|
||||
}
|
||||
|
||||
RDEPENDS_${PN} = "smack python mmap-smack-test tcp-smack-test udp-smack-test"
|
||||
RDEPENDS:${PN} = "smack python mmap-smack-test tcp-smack-test udp-smack-test"
|
||||
|
||||
@@ -28,15 +28,15 @@ REQUIRED_DISTRO_FEATURES = "smack"
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
PACKAGECONFIG ??= ""
|
||||
PACKAGECONFIG_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
|
||||
PACKAGECONFIG:append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}"
|
||||
|
||||
PACKAGECONFIG[systemd] = "--with-systemdsystemunitdir=${systemd_system_unitdir}, --without-systemdsystemunitdir, systemd"
|
||||
|
||||
do_compile_append () {
|
||||
do_compile:append () {
|
||||
oe_runmake -C ${S}/tests generator
|
||||
}
|
||||
|
||||
do_install_append () {
|
||||
do_install:append () {
|
||||
install -d ${D}${sysconfdir}/init.d
|
||||
install -d ${D}${sysconfdir}/smack
|
||||
install -d ${D}${sysconfdir}/smack/accesses.d
|
||||
@@ -55,10 +55,10 @@ INITSCRIPT_PACKAGES = "${PN}"
|
||||
INITSCRIPT_NAME = "smack"
|
||||
INITSCRIPT_PARAMS = "start 16 2 3 4 5 . stop 35 0 1 6 ."
|
||||
|
||||
FILES_${PN} += "${sysconfdir}/init.d/smack"
|
||||
FILES_${PN}-ptest += "generator"
|
||||
FILES:${PN} += "${sysconfdir}/init.d/smack"
|
||||
FILES:${PN}-ptest += "generator"
|
||||
|
||||
RDEPENDS_${PN} += "coreutils python3-core"
|
||||
RDEPENDS_${PN}-ptest += "make bash bc"
|
||||
RDEPENDS:${PN} += "coreutils python3-core"
|
||||
RDEPENDS:${PN}-ptest += "make bash bc"
|
||||
|
||||
BBCLASSEXTEND = "native"
|
||||
|
||||
@@ -1,111 +1,111 @@
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <sys/xattr.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
int sock;
|
||||
char message[255] = "hello";
|
||||
struct sockaddr_in server_addr;
|
||||
char* label_in;
|
||||
char* label_out;
|
||||
char* attr_out = "security.SMACK64IPOUT";
|
||||
char* attr_in = "security.SMACK64IPIN";
|
||||
char out[256];
|
||||
int port;
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
struct hostent* host = gethostbyname("localhost");
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
perror("Client: Arguments missing, please provide socket labels");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label_in = argv[2];
|
||||
label_out = argv[3];
|
||||
|
||||
if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
perror("Client: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr_out, label_out, strlen(label_out), 0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute SMACK64IPOUT");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(fsetxattr(sock, attr_in, label_in, strlen(label_in), 0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
bcopy((char*) host->h_addr, (char*) &server_addr.sin_addr.s_addr,host->h_length);
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Client: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&server_addr,sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
perror("Client: Connection failure");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(write(sock, message, strlen(message)) < 0)
|
||||
{
|
||||
perror("Client: Error sending data\n");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
#include <sys/xattr.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
int sock;
|
||||
char message[255] = "hello";
|
||||
struct sockaddr_in server_addr;
|
||||
char* label_in;
|
||||
char* label_out;
|
||||
char* attr_out = "security.SMACK64IPOUT";
|
||||
char* attr_in = "security.SMACK64IPIN";
|
||||
char out[256];
|
||||
int port;
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
struct hostent* host = gethostbyname("localhost");
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
perror("Client: Arguments missing, please provide socket labels");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label_in = argv[2];
|
||||
label_out = argv[3];
|
||||
|
||||
if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
perror("Client: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr_out, label_out, strlen(label_out), 0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute SMACK64IPOUT");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(fsetxattr(sock, attr_in, label_in, strlen(label_in), 0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
bcopy((char*) host->h_addr, (char*) &server_addr.sin_addr.s_addr,host->h_length);
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Client: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&server_addr,sizeof(struct sockaddr)) == -1)
|
||||
{
|
||||
perror("Client: Connection failure");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(write(sock, message, strlen(message)) < 0)
|
||||
{
|
||||
perror("Client: Error sending data\n");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
close(sock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,118 +1,118 @@
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
int sock;
|
||||
int clientsock;
|
||||
char message[255];
|
||||
socklen_t client_length;
|
||||
struct sockaddr_in server_addr, client_addr;
|
||||
char* label_in;
|
||||
char* attr_in = "security.SMACK64IPIN";
|
||||
int port;
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
perror("Server: Argument missing please provide port and label for SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label_in = argv[2];
|
||||
bzero(message,255);
|
||||
|
||||
|
||||
if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
perror("Server: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr_in, label_in, strlen(label_in),0) < 0)
|
||||
{
|
||||
perror("Server: Unable to set attribute ipin 2");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Server: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(bind(sock, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0)
|
||||
{
|
||||
perror("Server: Bind failure ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
listen(sock, 1);
|
||||
client_length = sizeof(client_addr);
|
||||
|
||||
clientsock = accept(sock,(struct sockaddr*) &client_addr, &client_length);
|
||||
|
||||
if (clientsock < 0)
|
||||
{
|
||||
perror("Server: Connection failed");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(clientsock, "security.SMACK64IPIN", label_in, strlen(label_in),0) < 0)
|
||||
{
|
||||
perror(" Server: Unable to set attribute ipin 2");
|
||||
close(sock);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(read(clientsock, message, 254) < 0)
|
||||
{
|
||||
perror("Server: Error when reading from socket");
|
||||
close(clientsock);
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
close(clientsock);
|
||||
close(sock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <stdio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
int sock;
|
||||
int clientsock;
|
||||
char message[255];
|
||||
socklen_t client_length;
|
||||
struct sockaddr_in server_addr, client_addr;
|
||||
char* label_in;
|
||||
char* attr_in = "security.SMACK64IPIN";
|
||||
int port;
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
perror("Server: Argument missing please provide port and label for SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label_in = argv[2];
|
||||
bzero(message,255);
|
||||
|
||||
|
||||
if((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
{
|
||||
perror("Server: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr_in, label_in, strlen(label_in),0) < 0)
|
||||
{
|
||||
perror("Server: Unable to set attribute ipin 2");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Server: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(bind(sock, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0)
|
||||
{
|
||||
perror("Server: Bind failure ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
listen(sock, 1);
|
||||
client_length = sizeof(client_addr);
|
||||
|
||||
clientsock = accept(sock,(struct sockaddr*) &client_addr, &client_length);
|
||||
|
||||
if (clientsock < 0)
|
||||
{
|
||||
perror("Server: Connection failed");
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(clientsock, "security.SMACK64IPIN", label_in, strlen(label_in),0) < 0)
|
||||
{
|
||||
perror(" Server: Unable to set attribute ipin 2");
|
||||
close(sock);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(read(clientsock, message, 254) < 0)
|
||||
{
|
||||
perror("Server: Error when reading from socket");
|
||||
close(clientsock);
|
||||
close(sock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
close(clientsock);
|
||||
close(sock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,75 +1,75 @@
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* message = "hello";
|
||||
int sock, ret;
|
||||
struct sockaddr_in server_addr;
|
||||
struct hostent* host = gethostbyname("localhost");
|
||||
char* label;
|
||||
char* attr = "security.SMACK64IPOUT";
|
||||
int port;
|
||||
if (argc != 3)
|
||||
{
|
||||
perror("Client: Argument missing, please provide port and label for SMACK64IPOUT");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label = argv[2];
|
||||
sock = socket(AF_INET, SOCK_DGRAM,0);
|
||||
if(sock < 0)
|
||||
{
|
||||
perror("Client: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr, label, strlen(label),0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
bcopy((char*) host->h_addr, (char*) &server_addr.sin_addr.s_addr,host->h_length);
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
ret = sendto(sock, message, strlen(message),0,(const struct sockaddr*)&server_addr,
|
||||
sizeof(struct sockaddr_in));
|
||||
|
||||
close(sock);
|
||||
if(ret < 0)
|
||||
{
|
||||
perror("Client: Error sending message\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
char* message = "hello";
|
||||
int sock, ret;
|
||||
struct sockaddr_in server_addr;
|
||||
struct hostent* host = gethostbyname("localhost");
|
||||
char* label;
|
||||
char* attr = "security.SMACK64IPOUT";
|
||||
int port;
|
||||
if (argc != 3)
|
||||
{
|
||||
perror("Client: Argument missing, please provide port and label for SMACK64IPOUT");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label = argv[2];
|
||||
sock = socket(AF_INET, SOCK_DGRAM,0);
|
||||
if(sock < 0)
|
||||
{
|
||||
perror("Client: Socket failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr, label, strlen(label),0) < 0)
|
||||
{
|
||||
perror("Client: Unable to set attribute ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
bcopy((char*) host->h_addr, (char*) &server_addr.sin_addr.s_addr,host->h_length);
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
ret = sendto(sock, message, strlen(message),0,(const struct sockaddr*)&server_addr,
|
||||
sizeof(struct sockaddr_in));
|
||||
|
||||
close(sock);
|
||||
if(ret < 0)
|
||||
{
|
||||
perror("Client: Error sending message\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,93 +1,93 @@
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int sock,ret;
|
||||
struct sockaddr_in server_addr, client_addr;
|
||||
socklen_t len;
|
||||
char message[5];
|
||||
char* label;
|
||||
char* attr = "security.SMACK64IPIN";
|
||||
int port;
|
||||
|
||||
if(argc != 3)
|
||||
{
|
||||
perror("Server: Argument missing, please provide port and label for SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label = argv[2];
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
sock = socket(AF_INET,SOCK_DGRAM,0);
|
||||
if(sock < 0)
|
||||
{
|
||||
perror("Server: Socket error");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr, label, strlen(label), 0) < 0)
|
||||
{
|
||||
perror("Server: Unable to set attribute ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Server: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(bind(sock, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0)
|
||||
{
|
||||
perror("Server: Bind failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
len = sizeof(client_addr);
|
||||
ret = recvfrom(sock, message, sizeof(message), 0, (struct sockaddr*)&client_addr,
|
||||
&len);
|
||||
close(sock);
|
||||
if(ret < 0)
|
||||
{
|
||||
perror("Server: Error receiving");
|
||||
return 1;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// (C) Copyright 2015 Intel Corporation
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
#include <sys/socket.h>
|
||||
#include <stdio.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int sock,ret;
|
||||
struct sockaddr_in server_addr, client_addr;
|
||||
socklen_t len;
|
||||
char message[5];
|
||||
char* label;
|
||||
char* attr = "security.SMACK64IPIN";
|
||||
int port;
|
||||
|
||||
if(argc != 3)
|
||||
{
|
||||
perror("Server: Argument missing, please provide port and label for SMACK64IPIN");
|
||||
return 2;
|
||||
}
|
||||
|
||||
port = atoi(argv[1]);
|
||||
label = argv[2];
|
||||
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 15;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
sock = socket(AF_INET,SOCK_DGRAM,0);
|
||||
if(sock < 0)
|
||||
{
|
||||
perror("Server: Socket error");
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
if(fsetxattr(sock, attr, label, strlen(label), 0) < 0)
|
||||
{
|
||||
perror("Server: Unable to set attribute ");
|
||||
return 2;
|
||||
}
|
||||
|
||||
server_addr.sin_family = AF_INET;
|
||||
server_addr.sin_port = htons(port);
|
||||
server_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
bzero(&(server_addr.sin_zero),8);
|
||||
|
||||
|
||||
if(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
|
||||
{
|
||||
perror("Server: Set timeout failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if(bind(sock, (struct sockaddr*) &server_addr, sizeof(server_addr)) < 0)
|
||||
{
|
||||
perror("Server: Bind failure");
|
||||
return 2;
|
||||
}
|
||||
|
||||
len = sizeof(client_addr);
|
||||
ret = recvfrom(sock, message, sizeof(message), 0, (struct sockaddr*)&client_addr,
|
||||
&len);
|
||||
close(sock);
|
||||
if(ret < 0)
|
||||
{
|
||||
perror("Server: Error receiving");
|
||||
return 1;
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user