libselinux: update const qualifier of parameters in man pages
PATCH 1/3 libselinux: update const qualifier of parameters in man pages
Add missing const qualifier to parameters in the man pages to align them with <selinux/selinux.h>.
--- libselinux/man/man3/getexeccon.3 | 4 +-- libselinux/man/man3/security_compute_av.3 | 32 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-)
libselinux/man/man3/getexeccon.3 +2 -2
@@ -11,9 +11,9 @@ rpm_execcon \- run a helper for rpm in an appropriate security context .sp .BI "int getexeccon_raw(char **" context ); .sp -.BI "int setexeccon(char *" context ); +.BI "int setexeccon(const char *" context ); .sp -.BI "int setexeccon_raw(char *" context ); +.BI "int setexeccon_raw(const char *" context ); .sp .BI "int setexecfilecon(const char *" filename ", const char *" fallback_type ); .sp
libselinux/man/man3/security_compute_av.3 +16 -16
@@ -7,37 +7,37 @@ the SELinux policy database in the kernel .SH "SYNOPSIS" .B #include <selinux/selinux.h> .sp -.BI "int security_compute_av(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_create(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_name(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_create_name_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_relabel(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_relabel_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_user(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_compute_user_raw(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user_raw(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_validatetrans(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp -.BI "int security_validatetrans_raw(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp .BI "int security_get_initial_context(const char *" name ", char **" con ); .sp
Signature · 1 line
2.43.0
PATCH 2/3 libselinux: always set errno on context translation failure
Allow callers to expect errno is set on failure, e.g. other exported libselinux functions like setexecfilecon(3).
--- libselinux/src/setrans_client.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
libselinux/src/setrans_client.c +19 -3
@@ -92,8 +92,10 @@ send_request(int fd, uint32_t function, const char *data1, const char *data2)ssize_t count, expected;unsigned int i; -if (fd <0 ) +if (fd <0 ) { + errno =EINVAL ;return -1 ; + }if (!data1) data1 ="" ;
@@ -123,8 +125,12 @@ send_request(int fd, uint32_t function, const char *data1, const char *data2)while (((count =sendmsg (fd, &msgh,MSG_NOSIGNAL )) <0 ) && (errno ==EINTR )) ; -if (count <0 || count != expected) +if (count <0 ) +return -1 ; +if (count != expected) { + errno =EBADMSG ;return -1 ; + }return 0 ; }
@@ -140,8 +146,10 @@ receive_response(int fd, uint32_t function, char **outdata, int32_t * ret_val)struct iovec resp_data;ssize_t count; -if (fd <0 ) +if (fd <0 ) { + errno =EINVAL ;return -1 ; + } resp_hdr[0 ].iov_base = &func; resp_hdr[0 ].iov_len =sizeof (func);
@@ -151,11 +159,17 @@ receive_response(int fd, uint32_t function, char **outdata, int32_t * ret_val) resp_hdr[2 ].iov_len =sizeof (*ret_val);while (((count =readv (fd, resp_hdr,3 )) <0 ) && (errno ==EINTR )) ; +if (count <0 ) { +return -1 ; + } +if (count != (sizeof (func) +sizeof (data_size) +sizeof (*ret_val))) { + errno =EBADMSG ;return -1 ; }if (func != function || !data_size || data_size >MAX_DATA_BUF ) { + errno =EBADMSG ;return -1 ; }
@@ -172,6 +186,8 @@ receive_response(int fd, uint32_t function, char **outdata, int32_t * ret_val)if (count <0 || (uint32_t ) count != data_size || data[data_size -1 ] !='\0' ) {free (data); +if (count >=0 ) + errno =EBADMSG ;return -1 ; } *outdata = data;
Signature · 1 line
2.43.0
PATCH 3/3 libselinux: state setexecfilecon(3) sets errno on failure
In reply to Christian GöttscheThe other functions (getexeccon(3) and setexeccon(3)) from the man page also set errno on failure similar to the getcon(3) function family.
--- libselinux/man/man3/getexeccon.3 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
libselinux/man/man3/getexeccon.3 +3 -1
@@ -89,7 +89,9 @@ then executes the specified filename with the provided argument and environment arrays. . .SH "RETURN VALUE" -On error \-1 is returned. +On failure, \-1 is returned and +.I errno +is set appropriately. On success .BR getexeccon (),
Signature · 1 line
2.43.0
Quoted 5 lines · Christian Göttsche
Add missing const qualifier to parameters in the man pages to align them with <
selinux/selinux.h>.Signed-off-by Christian Göttsche <[email protected]>
For these three patches:
Quoted 83 lines
--- libselinux/man/man3/getexeccon.3 | 4 +-- libselinux/man/man3/security_compute_av.3 | 32 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-)libselinux/man/man3/getexeccon.3 +2
-2@@ -11,9 +11,9 @@ rpm_execcon \- run a helper for rpm in an appropriate security context .sp .BI "int getexeccon_raw(char **" context ); .sp -.BI "int setexeccon(char *" context ); +.BI "int setexeccon(const char *" context ); .sp -.BI "int setexeccon_raw(char *" context ); +.BI "int setexeccon_raw(const char *" context ); .sp .BI "int setexecfilecon(const char *" filename ", const char *" fallback_type ); .splibselinux/man/man3/security_compute_av.3 +16
-17@@ -7,37 +7,37 @@ the SELinux policy database in the kernel .SH "SYNOPSIS" .B #include <selinux/selinux.h> .sp -.BI "int security_compute_av(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_create(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_name(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_create_name_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_relabel(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_relabel_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_user(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_compute_user_raw(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user_raw(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_validatetrans(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp -.BI "int security_validatetrans_raw(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp .BI "int security_get_initial_context(const char *" name ", char **" con ); .sp --2.43.0
Quoted 4 lines · James Carter
Quoted 1 line · Christian Göttsche
Quoted 8 lines
Quoted 4 lines
Add missing const qualifier to parameters in the man pages to align them with <
selinux/selinux.h>.Signed-off-by Christian Göttsche <[email protected]>For these three patches:
Acked-by James Carter <[email protected]>
These three patches have been merged.
Thanks,
Jim
Quoted 83 lines
Quoted 83 lines
--- libselinux/man/man3/getexeccon.3 | 4 +-- libselinux/man/man3/security_compute_av.3 | 32 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-)libselinux/man/man3/getexeccon.3 +2
-2@@ -11,9 +11,9 @@ rpm_execcon \- run a helper for rpm in an appropriate security context .sp .BI "int getexeccon_raw(char **" context ); .sp -.BI "int setexeccon(char *" context ); +.BI "int setexeccon(const char *" context ); .sp -.BI "int setexeccon_raw(char *" context ); +.BI "int setexeccon_raw(const char *" context ); .sp .BI "int setexecfilecon(const char *" filename ", const char *" fallback_type ); .splibselinux/man/man3/security_compute_av.3 +16
-17@@ -7,37 +7,37 @@ the SELinux policy database in the kernel .SH "SYNOPSIS" .B #include <selinux/selinux.h> .sp -.BI "int security_compute_av(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_av_flags_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); +.BI "int security_compute_av_flags_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", access_vector_t "requested ", struct av_decision *" avd ); .sp -.BI "int security_compute_create(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_create_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_create_name(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_create_name_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); +.BI "int security_compute_create_name_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" objname ", char **" newcon ); .sp -.BI "int security_compute_relabel(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_relabel_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_relabel_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_member_raw(char *" scon ", char *" tcon ", security_class_t "tclass ", char **" newcon ); +.BI "int security_compute_member_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", char **" newcon ); .sp -.BI "int security_compute_user(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_compute_user_raw(char *" scon ", const char *" username ", char ***" con ); +.BI "int security_compute_user_raw(const char *" scon ", const char *" username ", char ***" con ); .sp -.BI "int security_validatetrans(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp -.BI "int security_validatetrans_raw(char *" scon ", const char *" tcon ", security_class_t "tclass ", char *" newcon ); +.BI "int security_validatetrans_raw(const char *" scon ", const char *" tcon ", security_class_t "tclass ", const char *" newcon ); .sp .BI "int security_get_initial_context(const char *" name ", char **" con ); .sp --2.43.0