diff --git a/fhem/FHEM/42_npmjs.pm b/fhem/FHEM/42_npmjs.pm index 71ed8ca5b..0a59b363a 100644 --- a/fhem/FHEM/42_npmjs.pm +++ b/fhem/FHEM/42_npmjs.pm @@ -111,11 +111,11 @@ sub Define($$) { if ( $init_done && !defined( $hash->{OLDDEF} ) ) { # presets for FHEMWEB - $attr{$name}{alias} = 'Node.js Update Status'; + $attr{$name}{alias} = 'Node.js Package Update Status'; $attr{$name}{devStateIcon} = 'npm.updates.available:security@red:outdated npm.is.up.to.date:security@green:outdated .*in.progress:system_fhem_reboot@orange warning.*:message_attention@orange error.*:message_attention@red'; $attr{$name}{group} = 'System'; - $attr{$name}{icon} = 'nodejs'; + $attr{$name}{icon} = 'npm-old'; $attr{$name}{room} = 'System'; } @@ -368,7 +368,8 @@ sub Set($$@) { else { return "NPM cannot be uninstalled from here" if ( - grep ( m/^(?:@([\w-]+)\/)?(npm)(?:@([\d\.=<>]+))?$/i, @args ) ); + grep ( m/^(?:@([\w-]+)\/)?(npm)(?:@([\d\.=<>]+|latest))?$/i, + @args ) ); $hash->{".fhem"}{npm}{cmd} = $cmd . " " . join( " ", @args ); } } @@ -552,7 +553,8 @@ sub FhemTrigger ($$) { foreach my $package ( split / /, $packages ) { next - unless ( $package =~ /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+))?$/ ); + unless ( + $package =~ /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+|latest))?$/ ); DoTrigger( $name, uc($trigger) . uc($cmd) . " $2", 1 ); } } @@ -695,7 +697,13 @@ sub ExecuteNpmCommand($) { my $cmdPrefix = ""; my $cmdSuffix = ""; - if ( $cmd->{host} =~ /^(?:(.*)@)?(.+)$/ && lc($2) ne "localhost" ) { + if ( $cmd->{host} =~ /^(?:(.*)@)?([^:]+)(?::(\d+))?$/ + && lc($2) ne "localhost" ) + { + my $port = ""; + if ($3) { + $port = "-p $3 "; + } # One-time action to add remote hosts key. # If key changes, user will need to intervene @@ -712,7 +720,8 @@ sub ExecuteNpmCommand($) { . 'grep -q -E "^${KEY% *}" ${HOME}/.ssh/known_hosts || echo "${KEY}" >> ${HOME}/.ssh/known_hosts; '; # wrap SSH command - $cmdPrefix .= 'ssh -oBatchMode=yes ' . ( $1 ? "$1@" : "" ) . $2 . ' \''; + $cmdPrefix .= + 'ssh -oBatchMode=yes ' . $port . ( $1 ? "$1@" : "" ) . $2 . ' \''; $cmdSuffix = '\' 2>&1'; } @@ -798,7 +807,7 @@ sub ExecuteNpmCommand($) { foreach my $package ( split / /, $1 ) { next unless ( $package =~ - /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+))?$/ ); + /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+|latest))?$/ ); push @packages, "homebridge" @@ -826,8 +835,8 @@ sub ExecuteNpmCommand($) { my @packages = ""; foreach my $package ( split / /, $1 ) { next - unless ( - $package =~ /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+))?$/ ); + unless ( $package =~ + /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+|latest))?$/ ); push @packages, $package; } my $pkglist = join( ' ', @packages ); @@ -843,7 +852,7 @@ sub ExecuteNpmCommand($) { foreach my $package ( split / /, $1 ) { next unless ( $package =~ - /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+))?$/ ); + /^(?:@([\w-]+)\/)?([\w-]+)(?:@([\d\.=<>]+|latest))?$/ ); push @packages, $package; } $pkglist = join( ' ', @packages ); @@ -1347,18 +1356,24 @@ sub ToDay() {
fhem ALL=NOPASSWD: ALL

+ This line may easily be added to a new file in /etc/sudoers.d/fhem and will automatically included to /etc/sudoers from there.
+ More restricted sudo settings are currently not supported.
+ Only checking for outdated packages does not require any privileged access at all!
+

Define


Readings @@ -1431,18 +1446,24 @@ sub ToDay() {
fhem ALL=NOPASSWD: ALL

+ Diese Zeile kann einfach in einer neuen Datei unter /etc/sudoers.d/fhem hinzugefügt werden und wird von dort automatisch in /etc/sudoers inkludiert.
+ Restriktiviere sudo Einstellungen sind derzeit nicht möglich.
+ Um nur die zu aktualisierenden Pakete zu überprüfen wird überhaupt kein priviligierter Zugriff benötigt!
+

Define


Readings