mirror of
https://github.com/rd235/cado
synced 2024-12-27 06:24:11 +01:00
Merge pull request #5 from mattiabiondi/master
PostInstall check, removed unused retvalue warnings, config.h patch
This commit is contained in:
commit
5e294e0a8c
@ -6,7 +6,7 @@ project(cado
|
|||||||
LANGUAGES C)
|
LANGUAGES C)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2 -O2 -Wall -pedantic")
|
||||||
|
|
||||||
set(LIBS_REQUIRED cap execs mhash pam pam_misc)
|
set(LIBS_REQUIRED cap execs mhash pam pam_misc)
|
||||||
|
|
||||||
@ -24,8 +24,8 @@ else (WITHEDITOR)
|
|||||||
endif (WITHEDITOR)
|
endif (WITHEDITOR)
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
"${PROJECT_SOURCE_DIR}/include/config.h.in"
|
"include/config.h.in"
|
||||||
"${PROJECT_SOURCE_DIR}/include/config.h"
|
"include/config.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(man)
|
add_subdirectory(man)
|
||||||
|
@ -5,27 +5,27 @@ add_executable(
|
|||||||
read_conf.c set_ambient_cap.c compute_digest.c file_utils.c
|
read_conf.c set_ambient_cap.c compute_digest.c file_utils.c
|
||||||
scado_parse.c cado_scado_check.c
|
scado_parse.c cado_scado_check.c
|
||||||
)
|
)
|
||||||
target_include_directories(cado PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(cado PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
cado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library}
|
cado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library}
|
||||||
${execs_library})
|
${execs_library})
|
||||||
|
|
||||||
add_executable(cadrop cadrop.c capset_from_namelist.c set_ambient_cap.c)
|
add_executable(cadrop cadrop.c capset_from_namelist.c set_ambient_cap.c)
|
||||||
target_include_directories(cadrop PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(cadrop PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)
|
||||||
target_link_libraries(cadrop ${cap_library})
|
target_link_libraries(cadrop ${cap_library})
|
||||||
|
|
||||||
add_executable(
|
add_executable(
|
||||||
scado scado.c pam_check.c file_utils.c compute_digest.c
|
scado scado.c pam_check.c file_utils.c compute_digest.c
|
||||||
capset_from_namelist.c scado_parse.c
|
capset_from_namelist.c scado_parse.c
|
||||||
)
|
)
|
||||||
target_include_directories(scado PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(scado PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
scado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library}
|
scado ${pam_library} ${pam_misc_library} ${cap_library} ${mhash_library}
|
||||||
${execs_library}
|
${execs_library}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(caprint caprint.c)
|
add_executable(caprint caprint.c)
|
||||||
target_include_directories(caprint PRIVATE ${PROJECT_SOURCE_DIR}/include)
|
target_include_directories(caprint PRIVATE ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include)
|
||||||
target_link_libraries(caprint ${cap_library})
|
target_link_libraries(caprint ${cap_library})
|
||||||
|
|
||||||
install(
|
install(
|
||||||
@ -34,11 +34,13 @@ install(
|
|||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
if(NOT DEBUILD)
|
||||||
CODE "execute_process(
|
install(
|
||||||
COMMAND ${CMAKE_COMMAND}
|
CODE "execute_process(
|
||||||
-DBINDIR=${CMAKE_INSTALL_FULL_BINDIR}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
-DLIBDIR=${CMAKE_INSTALL_FULL_LIBDIR}
|
-DBINDIR=${CMAKE_INSTALL_FULL_BINDIR}
|
||||||
-P ${PROJECT_SOURCE_DIR}/PostInstall.cmake
|
-DLIBDIR=${CMAKE_INSTALL_FULL_LIBDIR}
|
||||||
)"
|
-P ${PROJECT_SOURCE_DIR}/PostInstall.cmake
|
||||||
)
|
)"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
@ -198,7 +198,10 @@ int main(int argc, char*argv[])
|
|||||||
grantcap = reqcaps & okcaps;
|
grantcap = reqcaps & okcaps;
|
||||||
|
|
||||||
/* revert setgid mode */
|
/* revert setgid mode */
|
||||||
setuid(getuid());
|
if (setuid(getuid()) < 0) {
|
||||||
|
fprintf(stderr,"%s: setuid failure\n",progname);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
/* ask for pam authorization (usually password) if required */
|
/* ask for pam authorization (usually password) if required */
|
||||||
if (pam_check_required && pam_check(user_groups[0]) != PAM_SUCCESS) {
|
if (pam_check_required && pam_check(user_groups[0]) != PAM_SUCCESS) {
|
||||||
|
@ -43,7 +43,12 @@ static ssize_t fcompute_digest(int infd, int outfd, char *ascii_digest) {
|
|||||||
|
|
||||||
while ((n=read(infd,buf,BUFSIZE)) > 0) {
|
while ((n=read(infd,buf,BUFSIZE)) > 0) {
|
||||||
mhash(td, buf, n);
|
mhash(td, buf, n);
|
||||||
if (outfd >= 0) write(outfd, buf, n);
|
if (outfd >= 0) {
|
||||||
|
if (write(outfd, buf, n) < 0) {
|
||||||
|
n = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
rv += n;
|
rv += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/scado.c
19
src/scado.c
@ -97,12 +97,12 @@ static int editor_garbage_collect(char *path) {
|
|||||||
if(!(childpid = fork())) {
|
if(!(childpid = fork())) {
|
||||||
/* Child */
|
/* Child */
|
||||||
if(!fork()) {
|
if(!fork()) {
|
||||||
char c = 0;
|
|
||||||
/* Grandchild */
|
/* Grandchild */
|
||||||
if (close(checkpipe[1]) == 0 && setsid() > 0)
|
if (close(checkpipe[1]) == 0 && setsid() > 0) {
|
||||||
read(checkpipe[0], &c, 1);
|
char c;
|
||||||
if (c == 0)
|
if (read(checkpipe[0], &c, 1) == 0)
|
||||||
unlink(path);
|
unlink(path);
|
||||||
|
}
|
||||||
exit(0);
|
exit(0);
|
||||||
} else
|
} else
|
||||||
exit(0);
|
exit(0);
|
||||||
@ -115,7 +115,8 @@ static int editor_garbage_collect(char *path) {
|
|||||||
|
|
||||||
static void editor_garbage_collect_do_not_unlink(int fd) {
|
static void editor_garbage_collect_do_not_unlink(int fd) {
|
||||||
char c = 'K'; // keep it, any other non-null char would fit.
|
char c = 'K'; // keep it, any other non-null char would fit.
|
||||||
write(fd, &c, 1);
|
int n = write(fd, &c, 1);
|
||||||
|
(void) n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* command line selectable functions */
|
/* command line selectable functions */
|
||||||
@ -188,7 +189,7 @@ int scado_edit(char *progname, char *username, char *program_path) {
|
|||||||
char tmp_file[PATH_MAX];
|
char tmp_file[PATH_MAX];
|
||||||
char scado_file[PATH_MAX];
|
char scado_file[PATH_MAX];
|
||||||
char *editor;
|
char *editor;
|
||||||
char *args = NULL;
|
char *args;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
pid_t pid, xpid;
|
pid_t pid, xpid;
|
||||||
char digest_before[DIGESTSTRLEN + 1];
|
char digest_before[DIGESTSTRLEN + 1];
|
||||||
@ -242,9 +243,7 @@ int scado_edit(char *progname, char *username, char *program_path) {
|
|||||||
exit(ERROR_EXIT);
|
exit(ERROR_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf(&args, "%s %s", editor, tmp_file);
|
if (asprintf(&args, "%s %s", editor, tmp_file) < 0) {
|
||||||
|
|
||||||
if (args == NULL) {
|
|
||||||
exit(ERROR_EXIT);
|
exit(ERROR_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user