From 6267ac3bf13d2f4015f03cc27cc3c0c01262b2b5 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Thu, 21 May 2026 21:12:44 +0200 Subject: [PATCH] roleback --- CMakeLists.txt | 7 ---- settings.pl | 96 +++++++----------------------------------------- smart.conf.cmake | 4 -- 3 files changed, 14 insertions(+), 93 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07f3106..0c8d52e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/settings.pl b/settings.pl index 2648749..4cc511c 100644 --- a/settings.pl +++ b/settings.pl @@ -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/ + if( defined( $c[1] ) && $c[1] eq 'users_import' && defined( $c[2] ) && $c[2] ne '' ) { $want = $c[2]; } + # Compatibility route: + # /settings/users/add_new/ 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\n\t\tDebug user import:\n\t\t$line\n\t\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" . '' . "\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" . '' . "\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
-$debug_user_import_row - - - Debug defaults: - default_name=$default_name default_unix_user=$default_unix_user default_fullname=$default_fullname fullname=$fullname - EOF if( $c[2] eq 'add_new' ) diff --git a/smart.conf.cmake b/smart.conf.cmake index ae0e369..b0d5371 100644 --- a/smart.conf.cmake +++ b/smart.conf.cmake @@ -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;