Declare read-only arguments of run_part(s) const
run_part() and run_parts() do not modify their directory, name and action arguments. Also include the header in the implementation to provide the prototypes. useradd.c:2495:59: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual] 2495 | if (run_parts ("/etc/shadow-maint/useradd-pre.d", (char*)user_name, | ^ useradd.c:2495:24: warning: passing argument 1 of ‘run_parts’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 2495 | if (run_parts ("/etc/shadow-maint/useradd-pre.d", (char*)user_name, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from useradd.c:45: ../lib/run_part.h:2:22: note: expected ‘char *’ but argument is of type ‘const char *’ 2 | int run_parts (char *directory, char *name, char *action); | ~~~~~~^~~~~~~~~ useradd.c:2496:25: warning: passing argument 3 of ‘run_parts’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 2496 | "useradd")) { | ^~~~~~~~~
This commit is contained in:
parent
debea9b761
commit
a8166a86ed
@ -8,9 +8,10 @@
|
|||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <lib/prototypes.h>
|
#include <lib/prototypes.h>
|
||||||
|
#include "run_part.h"
|
||||||
#include "shadowlog_internal.h"
|
#include "shadowlog_internal.h"
|
||||||
|
|
||||||
int run_part (char *script_path, char *name, char *action)
|
int run_part (char *script_path, const char *name, const char *action)
|
||||||
{
|
{
|
||||||
int pid;
|
int pid;
|
||||||
int wait_status;
|
int wait_status;
|
||||||
@ -39,7 +40,7 @@ int run_part (char *script_path, char *name, char *action)
|
|||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int run_parts (char *directory, char *name, char *action)
|
int run_parts (const char *directory, const char *name, const char *action)
|
||||||
{
|
{
|
||||||
struct dirent **namelist;
|
struct dirent **namelist;
|
||||||
int scanlist;
|
int scanlist;
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
int run_part (char *script_path, char *name, char *action);
|
int run_part (char *script_path, const char *name, const char *action);
|
||||||
int run_parts (char *directory, char *name, char *action);
|
int run_parts (const char *directory, const char *name, const char *action);
|
||||||
|
@ -2492,7 +2492,7 @@ int main (int argc, char **argv)
|
|||||||
(!user_id || (user_id <= uid_max && user_id >= uid_min));
|
(!user_id || (user_id <= uid_max && user_id >= uid_min));
|
||||||
#endif /* ENABLE_SUBIDS */
|
#endif /* ENABLE_SUBIDS */
|
||||||
|
|
||||||
if (run_parts ("/etc/shadow-maint/useradd-pre.d", (char*)user_name,
|
if (run_parts ("/etc/shadow-maint/useradd-pre.d", user_name,
|
||||||
"useradd")) {
|
"useradd")) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -2715,7 +2715,7 @@ int main (int argc, char **argv)
|
|||||||
create_mail ();
|
create_mail ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (run_parts ("/etc/shadow-maint/useradd-post.d", (char*)user_name,
|
if (run_parts ("/etc/shadow-maint/useradd-post.d", user_name,
|
||||||
"useradd")) {
|
"useradd")) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user