Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Standards-Version: 3.9.4
Package: sophomorix-samba
Architecture: all
Pre-Depends: ldb-tools, libconfig-inifiles-perl, libnet-dns-perl, libnet-ldap-perl
Depends: libnss-winbind, libunicode-map8-perl, libnet-mac-perl, libnet-ldap-sid-perl, libdate-calc-perl, liblist-moreutils-perl, libstring-approx-perl, libjson-perl, libmath-round-perl, libfilesys-smbclient-perl, libhtml-tableextract-perl, liblatex-encode-perl, libterm-readkey-perl, libparallel-forkmanager-perl, cifs-utils, texlive-latex-base, texlive-fonts-recommended, texlive-lang-german
Depends: libnss-winbind, libunicode-map8-perl, libnet-mac-perl, libnet-ldap-sid-perl, libnetaddr-ip-perl, libdate-calc-perl, liblist-moreutils-perl, libstring-approx-perl, libjson-perl, libmath-round-perl, libfilesys-smbclient-perl, libhtml-tableextract-perl, liblatex-encode-perl, libterm-readkey-perl, libparallel-forkmanager-perl, cifs-utils, texlive-latex-base, texlive-fonts-recommended, texlive-lang-german
Description: Sophomorix for Samba 4
sophomorix-samba is a user management tool for Samba 4

Expand Down
1 change: 1 addition & 0 deletions development/debian-packages
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# all
DONE:libnet-ldap-perl # Net::ldap
DONE libunicode-map8-perl # password generation
DONE libnetaddr-ip-perl # IP subnet checks

# developer
ldap-utils
36 changes: 36 additions & 0 deletions sophomorix-samba/scripts/sophomorix-query
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $Data::Dumper::Terse = 1;
use JSON;
use Sophomorix::SophomorixBase qw(
analyze_smbcquotas_out
result_sophomorix_init
config_sophomorix_read
);
use Sophomorix::SophomorixSambaAD qw(
AD_bind_admin
Expand Down Expand Up @@ -82,6 +84,7 @@ my $testopt=GetOptions(\%options,
"query-ip=s",
"query-comp=s",
"query-user=s",
"prefer-ip=s",
"query-room=s"
);

Expand Down Expand Up @@ -186,6 +189,7 @@ Query room data with smbstatus command:
--smbstatus --query-ip <ip> (show room that contains computer with <ip>)
--smbstatus --query-comp <comp> (show room that contains computer <comp>)
--smbstatus --query-user <user> (show room where <user> is logged in)
--prefer-ip <ip> (optional: if there is a smb connection for <user> from <ip>, prefer it)
--smbstatus --query-room <room> (show room <room>)

Limit the query to one or more sophomorixStatus:
Expand Down Expand Up @@ -366,6 +370,20 @@ if (defined $options{'smbstatus'}){
#my $string=`cat /root/log1`;
my @lines=split("\n",$string);
#print "$string";
my $prefered_ip=NetAddr::IP->new("0.0.0.0/0");
if (defined $options{'prefer-ip'}){
$prefered_ip=NetAddr::IP->new($options{'prefer-ip'})
}
# TODO (XRM): get ignored ips or the file itself from config
my $ignored_networks_file="/etc/linuxmuster/sophomorix/sophomorix-query.ignored_nets.txt";
my @ignored_networks=();
my $count=0;
open(IGNORED_NETWORKS,"$ignored_networks_file") ||
die "ERROR: $ignored_networks_file not found!";
while(<IGNORED_NETWORKS>){
$ignored_networks[$count++] = NetAddr::IP->new($_);
}
close(IGNORED_NETWORKS);
# first loop: get computers
foreach my $entry (@lines){
my ($pid)=split(/ /,$entry);
Expand All @@ -385,11 +403,29 @@ if (defined $options{'smbstatus'}){
$entry=~m/\\domain computers\s+([0-9.].*)\s+\(/;
my $ip=$1;

# ignore devices that are listed in ignore-list
my $net_ip = NetAddr::IP->new($ip);
my $ip_within_net = 0;
foreach my $network (@ignored_networks) {
if ($net_ip->within($network)) {
$ip_within_net = 1;
last;
}
}
if ($ip_within_net == 1) {
next;
}

# extract ipv4 from line
$entry=~m/ipv4:([0-9.].*)\)/;
my $ipv4_port=$1;
my ($ipv4,$port)=split(/:/,$ipv4_port);

# If a prefered ip is given, reconsider the current entry.
if (exists $smbstatus{'USER'}{$user} and !($net_ip->within($prefered_ip))) {
next;
}

# Save Data
$smbstatus{'COMPUTER'}{$computer}{'SMBSTATUS_LINE'}=$entry;
$smbstatus{'COMPUTER'}{$computer}{'PID'}=$pid;
Expand Down