This commit is contained in:
Mario Fetka
2026-05-21 21:12:44 +02:00
parent 7ce22da3ea
commit 6267ac3bf1
3 changed files with 14 additions and 93 deletions

View File

@@ -71,7 +71,6 @@ INCLUDE_DIRECTORIES(
add_executable(nwwebui nwwebui.c)
add_executable(check_login check_login.c)
add_executable(smart_userlist smart_userlist.c)
#################################
# Linking
@@ -87,11 +86,6 @@ target_link_libraries(check_login
${DL_LIBRARY}
)
target_link_libraries(smart_userlist
${PAM_LIBRARY}
${DL_LIBRARY}
)
#################################
# Install Files
##############
@@ -135,7 +129,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mars-nwe-webui.service DESTINATION ${S
endif()
install(TARGETS check_login DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR})
install(TARGETS smart_userlist DESTINATION ${MARS_NWE_INSTALL_FULL_LIBEXECDIR})
install(TARGETS nwwebui DESTINATION ${CMAKE_INSTALL_SBINDIR})

View File

@@ -650,7 +650,7 @@ sub sync_server_hint_row( $$$$ )
sub unix_user_import_rows()
{
my $html = '';
my @users = unix_userlist_effective();
my @users = unix_userlist();
my %existing = ();
my @candidates = ();
@@ -708,24 +708,28 @@ sub unix_user_defaults_from_query()
my $want = '';
if( defined( $p{unix_user} ) && $p{unix_user} ne '' )
{
$want = $p{unix_user};
}
elsif( defined( $c[1] ) && $c[1] eq 'users_import' && defined( $c[2] ) && $c[2] ne '' )
# Preferred import route:
# /settings/users_import/<unixuser>
if( defined( $c[1] ) && $c[1] eq 'users_import' && defined( $c[2] ) && $c[2] ne '' )
{
$want = $c[2];
}
# Compatibility route:
# /settings/users/add_new/<unixuser>
elsif( defined( $c[3] ) && $c[3] ne '' )
{
$want = $c[3];
}
elsif( defined( $p{unix_user} ) && $p{unix_user} ne '' )
{
$want = $p{unix_user};
}
if( $want ne '' )
{
$want =~ s/[^-_\.A-Za-z0-9]//g;
foreach my $u ( unix_userlist_effective() )
foreach my $u ( unix_userlist() )
{
next if ! defined( $u->{name} ) || $u->{name} ne $want;
@@ -785,71 +789,6 @@ sub smart_group_checkbox_rows( $ )
}
sub smart_debug_user_import_row()
{
my $p_unix = defined( $p{unix_user} ) ? $p{unix_user} : '';
my $line = '';
$line .= 'c0=' . html_escape( defined( $c[0] ) ? $c[0] : '' ) . ' ';
$line .= 'c1=' . html_escape( defined( $c[1] ) ? $c[1] : '' ) . ' ';
$line .= 'c2=' . html_escape( defined( $c[2] ) ? $c[2] : '' ) . ' ';
$line .= 'c3=' . html_escape( defined( $c[3] ) ? $c[3] : '' ) . ' ';
$line .= 'c4=' . html_escape( defined( $c[4] ) ? $c[4] : '' ) . ' ';
$line .= 'p_unix_user=' . html_escape( $p_unix );
return qq|\t<TR BGCOLOR="#fff8ea">\n\t\t<TD><B>Debug user import:</B></TD>\n\t\t<TD ALIGN=RIGHT><SMALL><TT>$line</TT></SMALL></TD>\n\t</TR>\n|;
}
sub unix_userlist_effective()
{
my @users = ();
if( defined( $smart_userlist_path ) && $smart_userlist_path ne '' && -x $smart_userlist_path )
{
my @cmd = ( $smart_userlist_path );
if( defined( $smart_userlist_pam_check ) && $smart_userlist_pam_check )
{
push( @cmd, '--pam-check' );
push( @cmd, '--pam-service', 'smart' );
}
if( open( my $fh, '-|', @cmd ) )
{
while( my $line = <$fh> )
{
chomp( $line );
my( $name, $uid, $gid, $gecos, $home, $shell ) = split( /\t/, $line, 6 );
next if ! defined( $name ) || $name eq '';
next if $name =~ /[^-_\.A-Za-z0-9]/;
push( @users, {
name => $name,
uid => $uid,
gid => $gid,
gecos => defined( $gecos ) ? $gecos : '',
home => defined( $home ) ? $home : '',
shell => defined( $shell ) ? $shell : '',
} );
}
close( $fh );
}
}
# Last-resort compatibility fallback: old SMArT unix_userlist() implementation.
if( scalar( @users ) == 0 )
{
@users = unix_userlist();
}
return @users;
}
sub handle_request()
{
if( $c[1] eq 'general' )
@@ -1394,7 +1333,7 @@ EOF
( $root_name, $root, $root_password ) = split( ' ', getconfigline( 12 ) );
$guest_user_list = '';
$root_list = '';
foreach $u ( unix_userlist_effective() )
foreach $u ( unix_userlist() )
{
if( $u->{uid} eq $guest )
{ $guest_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{uid} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
@@ -2543,7 +2482,6 @@ EOF
}
else
{
my $debug_user_import_row = smart_debug_user_import_row();
my $group_rows = smart_group_checkbox_rows( $server );
my %unix_defaults = unix_user_defaults_from_query();
my $default_name = $unix_defaults{name};
@@ -2559,7 +2497,7 @@ EOF
{
$fullname = read_property_string( $c[2], 1, 'IDENTIFICATION' );
$unix_user = read_property_string( $c[2], 1, 'UNIX_USER' );
foreach $u ( unix_userlist_effective() )
foreach $u ( unix_userlist() )
{
if( $u->{name} eq $unix_user )
{ $unix_user_list .= "\t\t\t" . '<OPTION VALUE="' . $u->{name} . '" SELECTED>' . $u->{name} . '</OPTION>' . "\n"; }
@@ -2580,7 +2518,7 @@ EOF
{
$fullname = $default_fullname;
foreach $u ( unix_userlist_effective() )
foreach $u ( unix_userlist() )
{
if( defined( $default_unix_user ) && $default_unix_user ne '' && $u->{name} eq $default_unix_user )
{
@@ -2659,12 +2597,6 @@ $settings_nav_bar
<IMG SRC="/static/smart_icon.jpg"><BR>
</TD>
</TR>
$debug_user_import_row
<TR BGCOLOR="#fff8ea">
<TD><B>Debug defaults:</B></TD>
<TD ALIGN=RIGHT><SMALL><TT>default_name=$default_name default_unix_user=$default_unix_user default_fullname=$default_fullname fullname=$fullname</TT></SMALL></TD>
</TR>
EOF
if( $c[2] eq 'add_new' )

View File

@@ -146,7 +146,3 @@ $nw_cert_file = '@MARS_NWE_INSTALL_FULL_CONFDIR@/server.crt';
# TLS private key file in PEM format.
# Required only when HTTPS is enabled.
$nw_key_file = '@MARS_NWE_INSTALL_FULL_CONFDIR@/server.key';
# Helper used by SMArT to list Unix/NSS users.
$smart_userlist_path = '@MARS_NWE_INSTALL_FULL_LIBEXECDIR@/smart_userlist';
$smart_userlist_pam_check = 0;