From patchwork Fri Jun 23 04:01:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6946 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpV6DlZz3wjw for ; Fri, 23 Jun 2023 04:01:38 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpS6s7wz1Ps; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpS55lvz30Bd; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpQ4x3Dz2xY5 for ; Fri, 23 Jun 2023 04:01:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpP4m9gzbW; Fri, 23 Jun 2023 04:01:33 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T0oK3VidZHC0XLOBtZFzGK0SSdReP0cL+qbIsoh3nOU=; b=BLE5NLd1OVVELf3KnZuMeJCl6bHxn5HM/BuK05wxUCkqHNnP7sRQ1CCqrXmBSFIj/sZq2D hvLbaABKDLgZMcAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=T0oK3VidZHC0XLOBtZFzGK0SSdReP0cL+qbIsoh3nOU=; b=fYI9EIbVrxIcG/f2oee6S6YnMF0s4olBAThsQ8P90sNHGLjAi2vbdXbC8pP0babVo8pi07 rRfUB93zhmSzBD+UFqDSlP3YvEtsxgv59hjh8y3hLoDkRaPrIECX77Yf4/1DgP/lykytxr KlL22HF5Fxqga8Y4nrT1gaQRCozg5e9wk3j/JV2iqPAHv2eM7LKG5EasELCWX8I8jo1Qxc RHrOToVQyWPXiLWBcTKJve7qyaaOC3QEBdBT8sXB29S632ifjFb0KAUmIuBcATYCqvQpGd UCoyg2YmSzpC5zunJfqlAXeKhDvEP8xHvB6eIwA1WUGULfuCEqbQyCbhQD+rAg== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 1/8] extrahd.cgi: Add various perl functions deal with block devices Date: Fri, 23 Jun 2023 06:01:17 +0200 Message-Id: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This functions are going to replace the former used scan/write to file/read from file approach by directly collecting the required informations from the kernel sysfs and devfs. Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 360 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 360 insertions(+) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 36c0efc2e..44065a8a1 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -255,3 +255,363 @@ END &Header::closebigbox(); &Header::closepage(); + +# +## Function which return an array with all available block devices. +# +sub get_block_devices () { + my @devices; + + # Open directory from kernel sysfs. + opendir(DEVICES, "/sys/block"); + + # Loop through the directory. + while(readdir(DEVICES)) { + # Skip . and .. + next if($_ =~ /^\.$/); + next if($_ =~ /^\..$/); + + # Skip any loopback and ram devices. + next if($_ =~ "^loop"); + next if($_ =~ "^ram"); + + # Add the device to the array of found devices. + push(@devices, $_); + } + + # Close directory handle. + closedir(DEVICES); + + # Return the devices array. + return @devices; +} + +# +## Function which return all partitions of a given block device. +# +sub get_device_partitions ($) { + my ($device) = @_; + + # Array to store the known partitions for the given + # device. + my @partitions; + + # Assign device directory. + my $device_dir = "$sysfs_block_dir/$device"; + + # Abort and return nothing if the device dir does not exist. + return unless(-d "$device_dir"); + + opendir(DEVICE, "$sysfs_block_dir/$device"); + while(readdir(DEVICE)) { + next unless($_ =~ "^$device"); + + push(@partitions, $_); + } + + closedir(DEVICE); + + @partitions = sort(@partitions); + + return @partitions; +} + +# +## Returns the vendor of a given block device. +# +sub get_device_vendor ($) { + my ($device) = @_; + + # Assign device directory. + my $device_dir = "$sysfs_block_dir/$device"; + + # Abort and return nothing if the device dir does not exist + # or no vendor file exists. + return unless(-d "$device_dir"); + return unless(-f "$device_dir/device/vendor"); + + # Open and read-in the device vendor. + open(VENDOR, "$device_dir/device/vendor"); + my $vendor = ; + close(VENDOR); + + # Abort and return nothing if no vendor could be read. + return unless($vendor); + + # Remove any newlines from the vendor string. + chomp($vendor); + + # Return the omited vendor. + return $vendor; +} + +# +## Returns the model name (string) of a given block device. +# +sub get_device_model ($) { + my ($device) = @_; + + # Assign device directory. + my $device_dir = "$sysfs_block_dir/$device"; + + # Abort and return nothing if the device dir does not exist + # or no model file exists. + return unless(-d "$device_dir"); + return unless(-f "$device_dir/device/model"); + + # Open and read-in the device model. + open(MODEL, "$device_dir/device/model"); + my $model = ; + close(MODEL); + + # Abort and return nothing if no model could be read. + return unless($model); + + # Remove any newlines from the model string. + chomp($model); + + # Return the model string. + return $model; +} + +# +## Returns the size of a given device in bytes. +# +sub get_device_size ($) { + my ($device) = @_; + + # Assign device directory. + my $device_dir = "$sysfs_block_dir/$device"; + + # Abort and return nothing if the device dir does not exist + # or no size file exists. + return unless(-d "$device_dir"); + return unless(-f "$device_dir/size"); + + # Open and read-in the device size. + open(SIZE, "$device_dir/size"); + my $size = ; + close(SIZE); + + # Abort and return nothing if the size could not be read. + return unless($size); + + # Remove any newlines for the size string. + chomp($size); + + # The omited size only contains the amount of blocks from the + # given device. To convert this into bytes we have to multiply this + # value with 512 bytes for each block. This is a static value used by + # the linux kernel. + $size = $size * 512; + + # Return the size in bytes. + return $size; +} + +# +## Function which returns all currently mounted devices as a hash. +## example: "sda1" -> "/boot" +# +sub get_mountpoints () { + my %mounts; + + # Open and read-in the current mounts from the + # kernel file system. + open(MOUNT, "/proc/mounts"); + + # Loop through the known mounts. + while() { + # Skip mounts which does not belong to a device. + next unless ($_ =~ "^/dev"); + + # Cut the line into pieces and assign nice variables. + my ($dev, $mpoint, $fs, $options, $a, $b) = split(/ /, $_); + + # Split the device name. + my @tmp = split("/", $dev); + + # Assign the plain device name to a new variable. + # It is the last element of the array. + my $device = $tmp[-1]; + + # Add the mountpoint to the hash of mountpoints. + $mounts{"$device"} = $mpoint; + } + + # Close file handle. + close(MOUNT); + + # Return the hash of known mountpoints. + return %mounts; +} + +sub get_swaps () { + my @swaps; + + # Open and read the swaps file. + open(SWAP, "/proc/swaps"); + + # Loop though the file content. + while() { + # Skip lines which does not belong to a device. + next unless ($_ =~ "^/dev"); + + # Split the line and assign nice variables. + my ($dev, $type, $size, $used, $prio) = split(/ /, $_); + + # Cut the device line into pieces. + my @tmp = split("/", $dev); + + my $device = @tmp[-1]; + + # Add the found swap to the array of swaps. + push(@swaps, $device); + } + + # Close file handle. + close(SWAP); + + # Sort the array. + @swaps = sort(@swaps); + + # Return the array. + return @swaps; +} + +# +## Function with returns the mounted devices and the used filesystems as a hash. +## Example: "sda1" -> "ext4" +# +sub get_mountedfs () { + my %mountedfs; + + # Open and read the current mounts from the kernel + # file system. + open(MOUNT, "/proc/mounts"); + + # Loop through the known mounts. + while() { + # Skip mounts which does not belong to a device. + next unless ($_ =~ "^/dev"); + + # Split line and assign nice variables. + my ($dev, $mpoint, $fs, $options, $a, $b) = split(/ /, $_); + + # Cut the device line into pieces. + my @tmp = split("/", $dev); + + # Assign the plain device name to a variable + # It is the last element of the temporary array. + my $device = $tmp[-1]; + + # Convert the filesystem into lower case format. + $fs = lc($fs); + + # Add the mounted file system. + $mountedfs{$device} = $fs; + } + + # Close file handle. + close(MOUNT); + + # Return the hash with the mounted filesystems. + return %mountedfs; +} + +# +## Function which returns all known UUID's as a hash. +## Example: "sda1" -> "1234-5678-abcd" +# +sub get_uuids () { + my %uuids; + + # Directory where the uuid mappings can be found. + my $uuid_dir = "/dev/disk/by-uuid"; + + # Open uuid directory and read-in the current known uuids. + opendir(UUIDS, "$uuid_dir"); + + # Loop through the uuids. + foreach my $uuid (readdir(UUIDS)) { + # Skip . and .. + next if($uuid eq "." or $uuid eq ".."); + + # Skip everything which is not a symbolic link. + next unless(-l "$uuid_dir/$uuid"); + + # Resolve the target of the symbolic link. + my $target = readlink("$uuid_dir/$uuid"); + + # Split the link target into pieces. + my @tmp = split("/", $target); + + # Assign the last element of the array to the dev variable. + my $dev = "$tmp[-1]"; + + # Add the device and uuid to the hash of uuids. + $uuids{$dev} = $uuid; + } + + # Close directory handle. + closedir(UUIDS); + + # Return the hash of uuids. + return %uuids; +} + +# +## Returns the device name of a given uuid. +# +sub device_by_uuid ($) { + my ($uuid) = @_; + + # Reverse the main uuids hash. + my %uuids = reverse %uuids; + + # Lookup and return the device name. + return $uuids{$uuid}; +} + +# +## Returns "True" in case a given path is a known mountpoint. +# +sub is_mounted ($) { + my ($mpoint) = @_; + + my %mountpoints = reverse %mountpoints; + + # Return "True" if the requested mountpoint is known and + # therefore mounted. + return 1 if($mountpoints{$mpoint}); +} + +# +## Returns "True" if a given mountpoint is a subdirectory of one +## of the directories specified by the valid_mount_dirs array abouve. +# +sub is_valid_dir ($) { + my ($mpoint) = @_; + + # Split the given mountpoint into pieces and store them + # in a temporay array. + my @tmp = split("/", $mpoint); + + # Exit and return nothing if the temporary array is empty. + return unless(@tmp); + + # Build the root path based on the given mount point. + my $root_path = "/" . @tmp[1]; + + # Check if the root path is valid. + return 1 if(grep /$root_path/, @valid_mount_dirs); +} + +# +# Returns "True" if a device is used as swap. +# +sub is_swap ($) { + my ($device) = @_; + + return 1 if(grep /$device/, @swaps); +} From patchwork Fri Jun 23 04:01:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6947 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpW5Zf5z3wmM for ; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpT6Dy0z1Z5; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpT5hjHz30Bd; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpR4HTtz2xY5 for ; Fri, 23 Jun 2023 04:01:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpR0YnbzhP; Fri, 23 Jun 2023 04:01:34 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M/4WbiOqXM7MqAtBKGPGNJByUINC0VrK2mmeqhOGAnw=; b=L4yCQ1wKPHKzWd3Q7tcfronB8Sfahz4bPRm58D+Gqb98u0jPrz1LogNiZZjRSuLF9Xoei3 2EyvVrYo43FZKoAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M/4WbiOqXM7MqAtBKGPGNJByUINC0VrK2mmeqhOGAnw=; b=m3BXPIubI9uO96IJJiOgN8TIyJTN/iy7p7fzqrx1djV8rVHD7+hK40opuGpsM+/tOvbh68 ycYvH80BZn/5T+cLV80iRdf1eub4pdfeGm7XoxgJq2Hu+tkQLksehdFXBNHweC/UtYdRVM fi7xv05hqSt+srfoASVHEs6DaVs/LCss9VnLH//tNzYsBFeP9xR1pWtReoQPPh7GZNiFYt KCMoyHE/z1o34ag99RZAeVH/9nJ3tLTkDNoYysWDPYbCND26Ol4VpdcmDIYuCezGlrkKVa v9gjVP3jUeS1H1sMdBMbRKHH+c8LPWrCyHzytkqOB+kM31+ZqWvbxsZB9Y6yZw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 2/8] extrahd.cgi: Refactor code to use new introduced perl functions. Date: Fri, 23 Jun 2023 06:01:18 +0200 Message-Id: <20230623040124.3826-2-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" This also gets rid of allmost all unsafe system calls. Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 336 ++++++++++++++++++++++++--------------- 1 file changed, 208 insertions(+), 128 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 44065a8a1..117890f08 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -29,33 +29,51 @@ require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %extrahdsettings = (); -my $message = ""; my $errormessage = ""; -my $size = ""; -my $ok = "true"; -my @tmp = (); -my @tmpline = (); -my $tmpentry = ""; -my @devices = (); -my @deviceline = (); -my $deviceentry = ""; -my @scans = (); -my @scanline = (); -my $scanentry = ""; -my @partitions = (); -my @partitionline = (); -my $partitionentry = ""; + +# SYSFS directory which contains all block device data. +my $sysfs_block_dir = "/sys/class/block"; + +# Array which contains the valid mount directories. +# Only mounting to subdirectories inside them is allowed. +my @valid_mount_dirs = ( + "/data", + "/media", + "/mnt", +); + +# Array which contains the supported file systems. +my @supported_filesystems = ( + "auto", + "ext3", + "ext4", + "xfs", + "vfat", + "ntfs-3g" +); + +# Grab all available block devices. +my @devices = &get_block_devices(); + +# Grab all known UUID's. +my %uuids = &get_uuids(); + +# Grab all mountpoints. +my %mountpoints = &get_mountpoints(); + +# Omit the file system types of the mounted devices. +my %filesystems = &get_mountedfs(); + +# Gather all used swap devices. +my @swaps = &get_swaps(); + +# The config file which contains the configured devices. my $devicefile = "/var/ipfire/extrahd/devices"; -my $scanfile = "/var/ipfire/extrahd/scan"; -my $partitionsfile = "/var/ipfire/extrahd/partitions"; #workaround to suppress a warning when a variable is used only once my @dummy = ( ${Header::colourgreen}, ${Header::colourred} ); undef (@dummy); -&General::system("/usr/local/bin/extrahdctrl", "scanhd", "ide"); -&General::system("/usr/local/bin/extrahdctrl", "scanhd", "partitions"); - &Header::showhttpheaders(); ### Values that have to be initialized @@ -65,7 +83,6 @@ $extrahdsettings{'DEVICE'} = ''; $extrahdsettings{'ACTION'} = ''; $extrahdsettings{'UUID'} = ''; -&General::readhash("${General::swroot}/extrahd/settings", \%extrahdsettings); &Header::getcgihash(\%extrahdsettings); &Header::openpage('ExtraHD', 1, ''); @@ -74,52 +91,88 @@ $extrahdsettings{'UUID'} = ''; ############################################################################################################################ ############################################################################################################################ -if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) -{ +# +## Add a new device. +# +if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { + # Open device file for reading. open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; - @devices = ; + my @devices = ; close FILE; - foreach $deviceentry (sort @devices) - { - @deviceline = split( /\;/, $deviceentry ); - if ( "$extrahdsettings{'PATH'}" eq "$deviceline[2]" ) { - $ok = "false"; + + # Loop through the entries line-by-line. + foreach my $entry (sort @devices) { + # Split the line into pieces and assign nice variables. + my ($uuid, $fs, $path) = split( /\;/, $entry ); + + # Check if the path is allready used. + if ( "$extrahdsettings{'PATH'}" eq "$path" ) { $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; } - if ( "$extrahdsettings{'PATH'}" eq "/" ) { - $ok = "false"; - $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to root'}."; + + # Check if the uuid is allready used. + if ("$extrahdsettings{'DEVICE'} eq $uuid") { + $errormessage = "$extrahdsettings{'DEVICE'} is allready mounted."; } } - if ( "$ok" eq "true" ) { + # Check if a valid mount path has been choosen. + unless(&is_valid_dir("$extrahdsettings{'PATH'}")) { + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to root'}."; + } + + # Check if the given path allready is mounted somewhere. + if(&is_mounted("$extrahdsettings{'PATH'}")) { + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; + } + + # Check if there was an error message. + unless($errormessage) { + # Re-open the device file for writing. open(FILE, ">> $devicefile" ) or die "Unable to write $devicefile"; - print FILE <; - close FILE; - open( FILE, "> $devicefile" ) or die "Unable to write $devicefile"; - foreach $deviceentry (sort @tmp) - { - @tmpline = split( /\;/, $deviceentry ); - if ( $tmpline[2] ne $extrahdsettings{'PATH'} ) - { - print FILE $deviceentry; - } + +# +# Remove an existing one. +# +} elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) { + # Call helper binary to unmount the device. + &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}"); + + # Open the device file for reading. + open(FILE, "< $devicefile" ) or die "Unable to read $devicefile"; + + # Read the file content into a temporary array. + my @tmp = ; + + # Close file handle. + close(FILE); + + # Re-open device file for writing. + open(FILE, "> $devicefile" ) or die "Unable to write $devicefile"; + + # Loop through the previous read file content. + foreach my $line (sort @tmp) { + # Split line content and assign nice variables. + my ($uuid, $fs, $path) = split( /\;/, $line ); + + # Write the line in case it does not contain our element to delete. + if ($path ne $extrahdsettings{'PATH'}) { + print FILE "$line"; } - close FILE; - } else { - $errormessage = "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd maybe the device is in use'}?"; } + + # Close file handle. + close(FILE); } if ($errormessage) { @@ -132,34 +185,38 @@ if ($errormessage) { ############################################################################################################################ ############################################################################################################################ - open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; - @devices = ; - close FILE; print < END ; - foreach $deviceentry (sort @devices) - { - @deviceline = split( /\;/, $deviceentry ); - my $color="$Header::colourred"; + # Re-read mountpoints. + %mountpoints = &get_mountpoints(); - # Use safe system_output to get mountpoint details. - my @mountpoint = &General::system_output("/bin/mountpoint", "$deviceline[2]"); + # Read-in the device config file. + open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; + my @configfile = ; + close FILE; + + # Loop through the file content. + foreach my $entry (sort @configfile) { + my ($uuid, $fs, $path) = split( /\;/, $entry ); + my $color="$Header::colourred"; - if ( ! grep(/not/, @mountpoint)) { + # Check if the device is currently mounted. + if (&is_mounted($path)) { $color=$Header::colourgreen; } + print <  - $deviceline[0] - $deviceline[1] - $deviceline[2] + $uuid + $fs + $path
- - - + + +
@@ -170,78 +227,101 @@ END END ; + &Header::openbox('100%', 'center', $Lang::tr{'extrahd detected drives'}); print < END ; - open( FILE, "< $scanfile" ) or die "Unable to read $scanfile"; - @scans = ; - close FILE; - open( FILE, "< $partitionsfile" ) or die "Unable to read $partitionsfile"; - @partitions = ; - close FILE; - foreach $scanentry (sort @scans) - { - @scanline = split( /\;/, $scanentry ); - # remove wrong entries like usb controller name - if ($scanline[1] ne "\n") - { - print <  - /dev/$scanline[0] - $scanline[1] + foreach my $device (sort @devices) { + # Grab the device details. + my $vendor = &get_device_vendor($device); + my $model = &get_device_model($device); + my $bsize = &get_device_size($device); + + # Convert size into human-readable format. + my $size = &General::formatBytes($bsize); + + print <  + /dev/$device + $vendor $model + + $Lang::tr{'size'} $size +   +   END ; - } - foreach $partitionentry (sort @partitions) - { - @partitionline = split( /\;/, $partitionentry ); - if ( "$partitionline[0]" eq "$scanline[0]" ) { - $size = int($partitionline[1] / 1024); - print <$Lang::tr{'size'} $size MB -   -   + # Grab the known partitions of the current block device. + my @partitions = &get_device_partitions($device); + + foreach my $partition (@partitions) { + my $disabled; + + # Omit the partition size. + my $bsize = &get_device_size($partition); + + # Convert into human-readable format. + my $size = &General::formatBytes($bsize); + + # Get the mountpoint. + my $mountpoint = $mountpoints{$partition}; + + if ($mountpoint eq "/" or $mountpoint =~ "^/boot") { + $disabled = "disabled"; + } elsif(&is_mounted($mountpoint)) { + $disabled = "disabled"; + } + + # Omit the used filesystem. + my $fs = $filesystems{$partition}; + + # Check if the device is used as swap. + if (&is_swap($partition)) { + $disabled = "disabled"; + $mountpoint = "swap"; + } + + print < + UUID=$uuids{$partition} + + /dev/$partition + $Lang::tr{'size'} $size + - - - - - - - - + # Mark the used filesystem as selected. + if ($filesystem eq $fs) { + $selected = "selected"; + } + + print "\n"; + } + + print < + - - + + - - END -; +; unless($disabled) { + print"\n"; + } + print < END -; - } - } +; } + } print < X-Patchwork-Id: 6948 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpX17y3z3wjw for ; Fri, 23 Jun 2023 04:01:40 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpV0LtGz1Np; Fri, 23 Jun 2023 04:01:38 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpT6Cq2z30GP; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpS1yPTz2xY5 for ; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpR5H7mzbW; Fri, 23 Jun 2023 04:01:35 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cMWuicTisBDtb9RhTHrB3XRRGDZFEukRHbqgS10ivfw=; b=t3jSo0360xuHTdXzbv2lnW2C7pYkaBb+hHVOheGA/8M1eMeF1grD+JSmmqzMeOYBvgKS+5 82Gl3n2iGEUHm/DQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cMWuicTisBDtb9RhTHrB3XRRGDZFEukRHbqgS10ivfw=; b=mglRHp3Qr8u0sMmTKRDc0k3CU8S4MX08U2eROSNe4BMzRlySUX4kd+Y4byZQXb83pGMLcA cEBbFmasqsK1jqa3stYmRI/+aQ9YThbWfhqnPPNGP1tgloGgGkW7gK5Hdnd0DFoJR67vbL he/xDIi2uDW0jMss3B2snJp+QCwibKjxRDayyJTpOd0ENXw2VTSII9L48EGGHuC/2K09c2 p2XrxkUIReZOPJy/3fssIc8vFY36cQlihpuRPalK6uL0HcFUS1xRQJF1l9ucyOemWN49vX Q0pgWaGqGmBswkVdgHwKT15bZ4ta3vXsyU511BPkc+taRu5pmsX9/bk7OdREbA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 3/8] extrahd.cgi: Abort if a device could not be umounted. Date: Fri, 23 Jun 2023 06:01:19 +0200 Message-Id: <20230623040124.3826-3-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 42 +++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 117890f08..dde4e7356 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -146,33 +146,35 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { # } elsif ($extrahdsettings{'ACTION'} eq $Lang::tr{'delete'}) { # Call helper binary to unmount the device. - &General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}"); + unless(&General::system("/usr/local/bin/extrahdctrl", "umount", "$extrahdsettings{'PATH'}")) { + # Open the device file for reading. + open(FILE, "< $devicefile" ) or die "Unable to read $devicefile"; - # Open the device file for reading. - open(FILE, "< $devicefile" ) or die "Unable to read $devicefile"; + # Read the file content into a temporary array. + my @tmp = ; - # Read the file content into a temporary array. - my @tmp = ; - - # Close file handle. - close(FILE); + # Close file handle. + close(FILE); - # Re-open device file for writing. - open(FILE, "> $devicefile" ) or die "Unable to write $devicefile"; + # Re-open device file for writing. + open(FILE, "> $devicefile" ) or die "Unable to write $devicefile"; - # Loop through the previous read file content. - foreach my $line (sort @tmp) { - # Split line content and assign nice variables. - my ($uuid, $fs, $path) = split( /\;/, $line ); + # Loop through the previous read file content. + foreach my $line (sort @tmp) { + # Split line content and assign nice variables. + my ($uuid, $fs, $path) = split( /\;/, $line ); - # Write the line in case it does not contain our element to delete. - if ($path ne $extrahdsettings{'PATH'}) { - print FILE "$line"; + # Write the line in case it does not contain our element to delete. + if ($path ne $extrahdsettings{'PATH'}) { + print FILE "$line"; + } } - } - # Close file handle. - close(FILE); + # Close file handle. + close(FILE); + } else { + $errormessage = "$Lang::tr{'extrahd cant umount'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd maybe the device is in use'}?"; + } } if ($errormessage) { From patchwork Fri Jun 23 04:01:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6949 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpY09ZFz3wmM for ; Fri, 23 Jun 2023 04:01:41 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpV1LJVz2SR; Fri, 23 Jun 2023 04:01:38 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpT6l4bz2xY5; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpS6Fpbz2xRH for ; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpS2VJkz1GG; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b6pWBIaoqM+6K3/xraJ9IbHWjs8LJMJm6hlRsigbs3o=; b=XBb4cYCED1cra8JTDN8NBloatf70pRYqyt+1ZorI6Rxb+k+P5wPDrcuNfwB29hVOVW8dCM /QnoTUR+N91W8FAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b6pWBIaoqM+6K3/xraJ9IbHWjs8LJMJm6hlRsigbs3o=; b=U4icPE05UgCjksWJKogpRqTphqrIwKoBlTSEzl44iaO7VTGGo9WFHm9CQR4CmvXZ+YU5AY V48YdXaHqTAwFlSeEYV1l1W5QG1S0rX2ma+0EpJElL2Idll/NlGu6DL6RdR8aei3R5DcHE bybC0s6Yg7KCyK3Ni6UCg8YK2sX4HtvqTnzmEq5nCh+itNLuPzpA3UsP7Rb1fblahTYwJg aZI14zZybQuRVizDbUXtiX5fL8197clLGrqdR4nar8P8Gp4k6OGt6+9iqfYOxTY7XQh17k pT/nU2JTMdOmDECQzYooFgZxGyRdGtoERlE8TgFn2Nybfc74OyP1AjJKAOTP0Q== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 4/8] extrahd.cgi: Store configured drives in a hash Date: Fri, 23 Jun 2023 06:01:20 +0200 Message-Id: <20230623040124.3826-4-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 71 ++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index dde4e7356..fc8685830 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -31,6 +31,9 @@ require "${General::swroot}/header.pl"; my %extrahdsettings = (); my $errormessage = ""; +# Hash to store the configured drives. +my %configured_drives; + # SYSFS directory which contains all block device data. my $sysfs_block_dir = "/sys/class/block"; @@ -187,50 +190,26 @@ if ($errormessage) { ############################################################################################################################ ############################################################################################################################ - print < -END -; +&Header::openbox('100%', 'center', $Lang::tr{'extrahd detected drives'}); + # Re-read mountpoints. %mountpoints = &get_mountpoints(); # Read-in the device config file. open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; - my @configfile = ; - close FILE; # Loop through the file content. - foreach my $entry (sort @configfile) { - my ($uuid, $fs, $path) = split( /\;/, $entry ); - my $color="$Header::colourred"; - - # Check if the device is currently mounted. - if (&is_mounted($path)) { - $color=$Header::colourgreen; - } + while () { + # Cut the line into pieces. + my ($uuid, $fs, $path) = split( /\;/, $_ ); - print <  - $uuid - $fs - $path - -
- - - - - -
-END -; + # Add the found entry to the hash of configured drives. + $configured_drives{$uuid} = $path; } - print < -END -; -&Header::openbox('100%', 'center', $Lang::tr{'extrahd detected drives'}); + # Close the file handle. + close(FILE); + print < END @@ -270,21 +249,35 @@ END # Get the mountpoint. my $mountpoint = $mountpoints{$partition}; + # If no mountpoint could be determined try to grab from + # configured drives. + unless($mountpoint) { + my $uuid = $uuids{$partition}; + + # Build uuid string. + $uuid = "UUID=" . $uuid; + + # Try to obtain a possible moutpoint from configured drives. + $mountpoint = $configured_drives{$uuid} if ($configured_drives{$uuid}); + } + + # Check if the mountpoint is used as root or boot device. if ($mountpoint eq "/" or $mountpoint =~ "^/boot") { $disabled = "disabled"; + + # Check if it is mounted. } elsif(&is_mounted($mountpoint)) { $disabled = "disabled"; - } - - # Omit the used filesystem. - my $fs = $filesystems{$partition}; # Check if the device is used as swap. - if (&is_swap($partition)) { + } elsif (&is_swap($partition)) { $disabled = "disabled"; $mountpoint = "swap"; } + # Omit the used filesystem. + my $fs = $filesystems{$partition}; + print < From patchwork Fri Jun 23 04:01:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6950 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpZ2XFxz3wjw for ; Fri, 23 Jun 2023 04:01:42 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpW2CPGz2ST; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpW0SJ1z30Bj; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpT4fzPz2yp4 for ; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpS6qfBz1Np; Fri, 23 Jun 2023 04:01:36 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bIf9mZxwPJcu7fSSSUKU8hQOtO88PEvHwO7Vedw8wfE=; b=mNY7NQsWn8O0by/XTUJVX/Ou3tl6N0oval1PzM7DWfbGatrtjQrW/MieLLR20Ox1MjXuTh m89SSYPwtXdTV7Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bIf9mZxwPJcu7fSSSUKU8hQOtO88PEvHwO7Vedw8wfE=; b=CyLj9barAqiov0KozOZP707JPsT2fx/qi7y41oA9/PoVyG/3cFl02SW00F49AHnosJwPXL JiZWFwvpYDzlqkzakuX+gQQK2WYDrtbD7Qc8w1w6NxFbp1azYkiYaeqsjn+XV5dN5bk4Ja xusHV5TXuNm2DGU8anU5mZZCir1xOp75XY4BvScJLaLxSqnxN8J3JXw5DeVyEg77lYZ/8w YIN/4FnXAse7Li4/ky+UFP4dZPh5wxu95Dn161H2YdGa6Aay3y2YfW25xEuH+BpjOOgXgM HSl7j6KeugpkapPcmzhbt67Rk2TtatJ+J3bYVjitfoQtw7mww493uHdakVVHdQ== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 5/8] extrahd.cgi: Add is_configured function. Date: Fri, 23 Jun 2023 06:01:21 +0200 Message-Id: <20230623040124.3826-5-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index fc8685830..533d0cdce 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -690,3 +690,15 @@ sub is_swap ($) { return 1 if(grep /$device/, @swaps); } + +# +## Returns "True" if a drive is a configured one. +# +sub is_configured ($) { + my ($path) = @_; + + # Loop through the hash of configured drives. + foreach my $uuid (keys %configured_drives) { + return 1 if($configured_drives{$uuid} eq "$path"); + } +} From patchwork Fri Jun 23 04:01:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6951 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpb3Nl3z3wmM for ; Fri, 23 Jun 2023 04:01:43 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpX2njcz2Sf; Fri, 23 Jun 2023 04:01:40 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpX1MRgz30GQ; Fri, 23 Jun 2023 04:01:40 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpW0m1jz30Cv for ; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpT6n4Zz2SM; Fri, 23 Jun 2023 04:01:37 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F2gklaxI1rwnUoQfkP/gLBzEmf59E7XfzYPk5gCi/PU=; b=YQxUl20jJa15YlO4vKtVGQSznwQ8X3b2Md6uoI3JBg5kO0MO1yt5EnKgT2COl5Z0Es4InA D4dP/VffXM2yf2Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F2gklaxI1rwnUoQfkP/gLBzEmf59E7XfzYPk5gCi/PU=; b=QXdvpTp3eOX8viDR6thQYLMfFFmYsb2rNtKe6FrKbrCzis7T0uV2pGdPO1yawcDCtPGale qVB/9RcF0ARG7pAMYIB+ogL26sLdUMRHDwZXtl+g2Xn1m8tgWPzysZCUNdKPkYIEpy28G/ CqJmmqMWY54H9myAoUaoZlH7c5jG4jd73vFQNcYRVQKqWvB2f2b55WfYTVjK7MwVajVQud 175gm3PaEVJzxOVuzZbkDSzdRK5pWTdtNMrAgMjJ1WqhO0VFsZG5qN9QMjnN15kzTOiDLt vvRu815h9692CngIt+x85RVpSNT4GL2VEM5jnTPy2KTc5I0YgJM9RL3r0QqpTA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 6/8] extrahd.cgi: Display mount status next to the corresponding drive Date: Fri, 23 Jun 2023 06:01:22 +0200 Message-Id: <20230623040124.3826-6-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 533d0cdce..a4d6e2e3a 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -302,14 +302,31 @@ END print < - + - END -; unless($disabled) { - print"\n"; +; + # Check if the mountpoint refers to a known configured drive. + if(&is_configured($mountpoint)) { + print "\n"; + print "\n"; + + # Check if the device is mounted properly. + if(&is_mounted($mountpoint)) { + print "MOUNTED \n"; + } else { + print "NOT MOUNTED \n"; + } + + print "\n"; + } else { + unless($disabled) { + print "\n"; + print "UNCONFIGURED \n"; + print "\n"; + } } print < X-Patchwork-Id: 6952 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpc3vPBz3wjw for ; Fri, 23 Jun 2023 04:01:44 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpX3WLbz2Sn; Fri, 23 Jun 2023 04:01:40 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpX1nJWz30HV; Fri, 23 Jun 2023 04:01:40 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpW3llYz2xYV for ; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpV5hFwz2SJ; Fri, 23 Jun 2023 04:01:38 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0R7sqsGZzUdME84mdiAYBYEvpW/QKqNrmBvPpcdsyfE=; b=d4r8aJAcBF268eakiuweZRxyi7BY9Fl2C2k/KT87gcXZyHOS6ZGNBdhiZhA0pD7o//wcWC i8Nlq2ZlS8v+1vCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0R7sqsGZzUdME84mdiAYBYEvpW/QKqNrmBvPpcdsyfE=; b=RinMlqIxF716SaB3SqtIcC0gEo/foAbAEXUjnJhLLa+O186iRQqa9aLiJYXcoJO+GAspKq T8w+SMDpZOwLYktWWrqADqZUgXFSAg1zhA/AX/a2nX2I12668A9b4Tbjq/7AZeEpLUodgc 5DjZKxLCa8KIgP8GNsxiBaXGadvB4sRcFu3VuU+0jbhbXHbrDZ2x/NcGFjH41PWu2IzWn3 XHE0a/fbdL54nJ9WNzFOmSOYEpgN9Dj3ntuFBMNAohZpLwAdR7nAJ/GdQzQD5QQFDDekJS JTFOBUkEEKDAN7Irv/VTv0i1YJcdABQjABygMFJv9Zw5nmduwdHWPoLbnwfySA== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 7/8] extrahd.cgi: Re-order sanity check logic Date: Fri, 23 Jun 2023 06:01:23 +0200 Message-Id: <20230623040124.3826-7-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 49 +++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index a4d6e2e3a..89ba19921 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -98,28 +98,7 @@ $extrahdsettings{'UUID'} = ''; ## Add a new device. # if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { - # Open device file for reading. - open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; - my @devices = ; - close FILE; - - # Loop through the entries line-by-line. - foreach my $entry (sort @devices) { - # Split the line into pieces and assign nice variables. - my ($uuid, $fs, $path) = split( /\;/, $entry ); - - # Check if the path is allready used. - if ( "$extrahdsettings{'PATH'}" eq "$path" ) { - $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; - } - - # Check if the uuid is allready used. - if ("$extrahdsettings{'DEVICE'} eq $uuid") { - $errormessage = "$extrahdsettings{'DEVICE'} is allready mounted."; - } - } - - # Check if a valid mount path has been choosen. + # Check if a valid mount path has been choosen. unless(&is_valid_dir("$extrahdsettings{'PATH'}")) { $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to root'}."; } @@ -129,7 +108,31 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; } - # Check if there was an error message. + # Check against may previously configured drives. + unless ($errormessage) { + # Open device file for reading. + open( FILE, "< $devicefile" ) or die "Unable to read $devicefile"; + my @devices = ; + close FILE; + + # Loop through the entries line-by-line. + foreach my $entry (sort @devices) { + # Split the line into pieces and assign nice variables. + my ($uuid, $fs, $path) = split( /\;/, $entry ); + + # Check if the path is allready used. + if ( "$extrahdsettings{'PATH'}" eq "$path" ) { + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; + } + + # Check if the uuid is allready used. + if ("$extrahdsettings{'DEVICE'} eq $uuid") { + $errormessage = "$extrahdsettings{'DEVICE'} is allready mounted."; + } + } + } + + # Go further if there was no error message. unless($errormessage) { # Re-open the device file for writing. open(FILE, ">> $devicefile" ) or die "Unable to write $devicefile"; From patchwork Fri Jun 23 04:01:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6953 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpf0HWrz3wjw for ; Fri, 23 Jun 2023 04:01:46 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4QnNpY2bPgz2SZ; Fri, 23 Jun 2023 04:01:41 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4QnNpY26hSz2yjT; Fri, 23 Jun 2023 04:01:41 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4QnNpW6qNWz2xlg for ; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4QnNpW2n5Pz2SZ; Fri, 23 Jun 2023 04:01:39 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1687492899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=15FAY9Cae23XHnjbNENPBBY/LVNq/b6BxIK7jkEkieo=; b=eN6kkiGY1i7uYIa4JWTyYoc6OI8vLgzgu6lP6esPBq5bQ14IMX/gGBlls8wTGA0bygXyOG mpFelUQ9+82U1oDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1687492899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=15FAY9Cae23XHnjbNENPBBY/LVNq/b6BxIK7jkEkieo=; b=rb7aivioAmwleZDKfpj2k44IqZ48YBpsOEK1Uf7W+Jx9SdQPQUmFmd/7NuxQ5dV/nAzVW5 D6nL+24veZK+fD4MEtJCZCKmnwMCDvG5zrV2jn3mFEYtR7eGlkiL4rph0u01g0UJRtb0Np qsTSWav9wq4HHvAsRdbsrMzFIsN1Biyie/5uNEzRdOra9TyK6WtCAdWUPcKHCeKNWvigYg Wgwm7GRZ/9GOUx184T3X0eMTMEfMffLhOk5pTuF2lsY+qk0ht/pXcNrIz87jloUSyuZKD1 C+gzugyK0UbGoEQyacotgI78I84PzPacCTOyvHBFhc0wDAlFym2iysI8LtGL6Q== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 8/8] extrahd.cgi: Add missing translation strings Date: Fri, 23 Jun 2023 06:01:24 +0200 Message-Id: <20230623040124.3826-8-stefan.schantl@ipfire.org> In-Reply-To: <20230623040124.3826-1-stefan.schantl@ipfire.org> References: <20230623040124.3826-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl --- html/cgi-bin/extrahd.cgi | 21 ++++++++++++--------- langs/de/cgi-bin/de.pl | 5 +++++ langs/en/cgi-bin/en.pl | 5 +++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/html/cgi-bin/extrahd.cgi b/html/cgi-bin/extrahd.cgi index 89ba19921..8f6a91a18 100644 --- a/html/cgi-bin/extrahd.cgi +++ b/html/cgi-bin/extrahd.cgi @@ -98,14 +98,17 @@ $extrahdsettings{'UUID'} = ''; ## Add a new device. # if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { + # Check if a mount path has been given. + if (not $extrahdsettings{'PATH'}) { + $errormessage = "$Lang::tr{'extrahd no mount point given'}."; + # Check if a valid mount path has been choosen. - unless(&is_valid_dir("$extrahdsettings{'PATH'}")) { - $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to root'}."; - } + } elsif(not &is_valid_dir("$extrahdsettings{'PATH'}")) { + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'} $Lang::tr{'extrahd because it is outside the allowed mount path'}."; # Check if the given path allready is mounted somewhere. - if(&is_mounted("$extrahdsettings{'PATH'}")) { - $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; + } elsif(&is_mounted("$extrahdsettings{'PATH'}")) { + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'} $Lang::tr{'extrahd because there is already a device mounted'}."; } # Check against may previously configured drives. @@ -122,7 +125,7 @@ if ($extrahdsettings{'ACTION'} eq $Lang::tr{'add'}) { # Check if the path is allready used. if ( "$extrahdsettings{'PATH'}" eq "$path" ) { - $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'}$Lang::tr{'extrahd because there is already a device mounted'}."; + $errormessage = "$Lang::tr{'extrahd you cant mount'} $extrahdsettings{'DEVICE'} $Lang::tr{'extrahd to'} $extrahdsettings{'PATH'} $Lang::tr{'extrahd because there is already a device mounted'}."; } # Check if the uuid is allready used. @@ -318,16 +321,16 @@ END # Check if the device is mounted properly. if(&is_mounted($mountpoint)) { - print "MOUNTED \n"; + print "$Lang::tr{ \n"; } else { - print "NOT MOUNTED \n"; + print "$Lang::tr{ \n"; } print "\n"; } else { unless($disabled) { print "\n"; - print "UNCONFIGURED \n"; + print "$Lang::tr{ \n"; print "\n"; } } diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 33730f0c3..37b17b431 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -1025,11 +1025,16 @@ 'external access rule removed' => ' Regel für externen Zugang entfernt; starte Zugangskontroller neu', 'external aliases configuration' => 'Externe Alias-Konfiguration', 'extrahd' => 'ExtraHD', +'extrahd because it is outside the allowed mount path' => 'mounten, da sich das Ziel außerhalb der erlaubten Pfade befindet', 'extrahd because there is already a device mounted' => ' mounten, weil bereits ein Gerät gemountet ist', 'extrahd cant umount' => 'Konnte', 'extrahd detected drives' => 'Gefundene Laufwerke', 'extrahd install or load driver' => 'Wenn Ihre Festplatte nicht angezeigt wird, müssen Sie zuerst den Treiber laden oder ggf. auch nachinstallieren. Wenn diese jedoch angezeigt wird, aber keine Partitionen zu sehen sind, müssen diese erst angelegt werden.', 'extrahd maybe the device is in use' => 'nicht mounten. Vielleicht wird das Gerät bereits verwendet', +'extrahd no mount point given' => 'Kein Pfad zum mounten angegeben', +'extrahd mounted' => 'Gemounted', +'extrahd not mounted' => 'Nicht gemounted', +'extrahd not configured' => 'Nicht konfiguriert', 'extrahd to' => 'nicht nach', 'extrahd to root' => 'nicht nach root mounten', 'extrahd unable to read' => 'Lesefehler von', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 729516538..b00ecc5eb 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -1072,11 +1072,16 @@ 'external access rule removed' => ' External access rule removed; restarting access controller', 'external aliases configuration' => 'External aliases configuration', 'extrahd' => 'ExtraHD', +'extrahd because it it outside the allowed mount path' => ', because it is outside the allowed mount path', 'extrahd because there is already a device mounted' => ', because there is already a device mounted', 'extrahd cant umount' => 'Can\'t umount', 'extrahd detected drives' => 'detected drives', 'extrahd install or load driver' => 'If your device isn\'t listed here, you need to install or load the driver.
If you can see your device but no partitions you have to create them first.', +'extrahd no mount point given', => 'No mount point given', 'extrahd maybe the device is in use' => '. Maybe the device is in use', +'extrahd mounted' => 'Mounted', +'extrahd not mounted' => 'Not mounted', +'extrahd not configured' => 'Not configured', 'extrahd to' => 'to', 'extrahd to root' => 'to root', 'extrahd unable to read' => 'Unable to read',