linux – pg_restore: error: could not read from input file (DBeaver for PostGreSQL in Oracle Virtual Machine), for .tar file

Using DBeaver21.0.3 for PostGreSQL13.2, on Oracle Virtual Machine on Oracle VirtualBox with Oracle linux7.9, in MacOS Catalina: (Did not install PgAdmin):

Trying to restore dvdrental.tar with following Restore Settings:

Format: custom
Backup File: /home/oracle/Downloads/dvdrental.tar
local client: /usr/bin

Getting error:

pg_restore: error: could not read from input file

sharepoint online – SPFX React npm WARN tar ENOENT: no such file or directory

I am trying to work on this react list form link , but when i try to do npm install i am getting all these errors below, i checked an article where they mentioned delete package-lock.json file but still no use. Any suggestions or thoughts on this ? Please let me know.

npm WARN tar ENOENT: no such file or directory, open ‘C:UsersDesktopreact-list-formnode_modules.staging@uifabricutilities-fd505e56lib-amdinitializeDir.js.map’

npm WARN tar ENOENT: no such file or directory, open ‘C:UsersDesktopreact-list-formnode_modules.staging@uifabricutilities-6f1ef562lib-amdIRectangle.js.map’

etc..

tar in pipe with gpg in remote mounted volume occupies space on root / partition

I wrote a code which scope is creating a tar encrypted with a password using gpg and sending it on a mounted remote volume.

tar --hard-dereference -cvzf - -C $filedir $basename | gpg -c --batch --passphrase-file $PASSPHRASEFILE > $encrypted_file;

IN the script the variable $encrypted_file is like:

/mnt/myvolume/filename

At the end of process I see that the file has been created in the remote volume, but I see also that the root partition increased its size.

Before tar:

Filesystem                                                        Size  Used Avail Use% 
Mounted on
udev                                                              3,9G     0  3,9G   0% /dev
tmpfs                                                             799M   84M  716M  11% /run
/dev/vda1                                                          79G   71G  5,4G  93% /

After tar:

Filesystem      Size  Used Avail Use% Mounted on
udev            3,9G     0  3,9G   0% /dev
tmpfs           799M   84M  716M  11% /run
/dev/vda1        79G   72G  3,8G  96% /

A reinventng the wheel PHP JWT library with minimal dependencies (PDO, JSON, mbstring) presented for ridicule, tar, & feathering

This is my first time posting here. This is so “reinventing the wheel” but, somewhat an earnest thing I wanted to try and a representative sample of where I am at in this skill. I would be grateful for any comments or suggestions that might make me a better developer tomorrow.

The code coverage is 100%, mostly as a good start for letting me know if I specifically broke something when I modify the code– specifically one of the things I would like to improve next year (tomorrow… as today is 2020-12-31) is expecting a specific RuntimeException message telling me that I am triggering the specific predicted runtime exception when I expect that I should get an exception in a particular place in the code.

The github link:
https://github.com/bradchesney79/effortless-hs256-jwt

A 20 minute Youtube video of stepping through the tests:
https://youtu.be/lx1FYXB6fB4

If you wanted to see any particular chunk in action– you can click to the area in the video you want to see happening. (Loading and running the code is still an option, but sometimes “I don’t wanna” and maybe you don’t either.)

The config file is essentially a php script that returns an array with the “secret” and database connection credentials.

I know revocation storage and handling is not part of JWT officially– but, I wanted it, so I baked it in complete with an SQL table creation script.

I really appreciate you spending your time looking at my thing.


<?php
namespace BradChesney79;
use DateTime;
use DateTimeZone;
use Exception;
use LogicException;
use PDO;
use RuntimeException;
class EHJWT
{
    /*
      iss: issuer, the website that issued the token
      sub: subject, the id of the entity being granted the token
      aud: audience, the users of the token-- generally a url or string
      exp: expires, the UTC UNIX epoch time stamp of when the token is no longer valid
      nbf: not before, the UTC UNIX epoch time stamp of when the token becomes valid
      iat: issued at, the UTC UNIX epoch time stamp of when the token was issued
      jti: JSON web token ID, a unique identifier for the JWT that facilitates revocation

      DB/MySQL limits:
      int has an unsigned, numeric limit of 4294967295
      bigint has an unsigned, numeric limit of 18446744073709551615
      unix epoch as of "now" 1544897945
    */

    /**
     * Token Claims
     *
     * @var array
     */
    private array $tokenClaims = array();
    /**
     * @var string
     */
    private string $token = '';
    /**
     * The config data.
     *
     * @var array
     */
    protected $configurations = ();

    //    /**
    //     * Error Object
    //     *
    //     * @var object
    //     */
    //    public object $error;

    // methods
    public function __construct(string $secret = '', string $configFileNameWithPath = '', string $dsn = '', string $dbUser = '', string $dbPassword = '')
    {
        try {
            $this->setConfigurationsFromEnvVars();
            if (mb_strlen($configFileNameWithPath) > 0) {
                $this->setConfigurationsFromConfigFile($configFileNameWithPath);
            }
            $this->setConfigurationsFromArguments($secret, $dsn, $dbUser, $dbPassword);
        } catch (Exception $e) {
            throw new LogicException('Failure creating EHJWT object: ' . $e->getMessage(), 0);
        }
        return true;
    }

    private function setConfigurationsFromEnvVars()
    {
        $envVarNames = array(
            'EHJWT_JWT_SECRET',
            'EHJWT_DSN',
            'EHJWT_DB_USER',
            'EHJWT_DB_PASS'
        );
        $settingConfigurationName = array(
            'jwtSecret',
            'dsn',
            'dbUser',
            'dbPassword'
        );
        for ($i = 0; $i < count($envVarNames); $i++) {
            $retrievedEnvironmentVariableValue = getenv($envVarNames($i));
            if (mb_strlen($retrievedEnvironmentVariableValue) > 0) {
                $this->configurations($settingConfigurationName($i)) = $retrievedEnvironmentVariableValue;
            }
        }
    }

    private function setConfigurationsFromConfigFile(string $configFileWithPath)
    {
        if (file_exists($configFileWithPath)) {
            $configFileSettings = require $configFileWithPath;
            if (gettype($configFileSettings) !== 'array') {
                throw new RuntimeException('EHJWT config file does not return an array');
            }
            if (count($configFileSettings) == 0) {
                trigger_error('No valid configurations received from EHJWT config file', 8);
            }
            foreach (array(
                         'jwtSecret',
                         'dsn',
                         'dbUser',
                         'dbPassword'
                     ) as $settingName) {
                $retrievedConfigFileVariableValue = $configFileSettings($settingName);
                if (mb_strlen($retrievedConfigFileVariableValue) > 0) {
                    $this->configurations($settingName) = $retrievedConfigFileVariableValue;
                }
            }
        }
    }

    private function setConfigurationsFromArguments(string $jwtSecret = '', string $dsn = '', string $dbUser = '', string $dbPassword = '')
    {
        foreach (array(
                     'jwtSecret',
                     'dsn',
                     'dbUser',
                     'dbPassword'
                 ) as $settingName) {
            $argumentValue = $
            {
            "$settingName"
            };
            if (mb_strlen($argumentValue) > 0) {
                $this->configurations($settingName) = $argumentValue;
            }
        }
    }

    public function addOrUpdateJwtClaim(string $key, $value, $requiredType = 'mixed')
    {
        // ToDo: Needs more validation or something ...added utf8
        if (gettype($value) == $requiredType || $requiredType === 'mixed') {
            if (mb_detect_encoding($value, 'UTF-8', true)) {
                $this->tokenClaims($key) = $value;
                return true;
            }
            throw new RuntimeException('Specified JWT claim required encoding mismatch');
        }
        throw new RuntimeException('Specified JWT claim required type mismatch');
    }

    public function clearClaim(string $key)
    {
        if (isset($key)) {
            unset($this->tokenClaims($key));
        }
        return true;
    }

    private function jsonEncodeClaims()
    {
        return json_encode($this->tokenClaims, JSON_FORCE_OBJECT);
    }

    private function createSignature($base64UrlHeader, $base64UrlClaims)
    {
        $jsonSignature = $this->makeHmacHash($base64UrlHeader, $base64UrlClaims);
        return $this->base64UrlEncode($jsonSignature);
    }

    public function createToken()
    {
        // !!! ksort to maintain properties in repeatable order
        ksort($this->tokenClaims);
        $jsonClaims = $this->jsonEncodeClaims();
        // The hash is always the same... don't bother computing it.
        $base64UrlHeader = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9';
        $base64UrlClaims = $this->base64UrlEncode($jsonClaims);
        $jsonSignature = $this->createSignature($base64UrlHeader, $base64UrlClaims);
        $base64UrlSignature = $this->base64UrlEncode($jsonSignature);
        $tokenParts = array(
            $base64UrlHeader,
            $base64UrlClaims,
            $base64UrlSignature
        );
        $this->token = implode('.', $tokenParts);
        return true;
    }

    public function getUtcTime()
    {
        $date = new DateTime('now', new DateTimeZone('UTC'));
        return $date->getTimestamp();
    }

    public function loadToken(string $tokenString)
    {
        $this->clearClaims();
        $this->token = $tokenString;
        if ($this->validateToken()) {
            $tokenParts = explode('.', $tokenString);
            $this->tokenClaims = $this->decodeTokenPayload($tokenParts(1));
            return true;
        }
        return false;
    }

    public function validateToken()
    {
        $tokenParts = $this->getTokenParts();
        $unpackedTokenPayload = $this->decodeTokenPayload($tokenParts(1));
        $this->tokenClaims = $unpackedTokenPayload;
        if ($tokenParts(0) !== 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9') {
            throw new RuntimeException('Encryption algorithm tampered with', 0);
        }
        $utcTimeNow = $this->getUtcTime();
        if (!isset($unpackedTokenPayload('exp'))) {
            throw new RuntimeException("Expiration standard claim for JWT missing", 0);
        }
        $expiryTime = $unpackedTokenPayload('exp');
        // a good JWT integration uses token expiration, I am forcing your hand
        if ($utcTimeNow > intval($expiryTime)) {
            // 'Expired (exp)'
            throw new RuntimeException('Token is expired', 0);
        }
        $notBeforeTime = $unpackedTokenPayload('nbf');
        // if nbf is set
        if (null !== $notBeforeTime) {
            if (intval($notBeforeTime) > $utcTimeNow) {
                // 'Too early for not before(nbf) value'
                throw new RuntimeException('Token issued before nbf header allows', 0);
            }
        }
        if (mb_strlen($this->configurations('dbUser')) > 0 && mb_strlen($this->configurations('dbPassword')) > 0) {
            if (strpos($this->configurations('dsn'), ':') === false) {
                throw new RuntimeException('No valid DSN stored for connection to DB', 0);
            }
            try {
                $dbh = $this->makeRevocationTableDatabaseConnection();
            } catch (Exception $e) {
                throw new RuntimeException('Cannot connect to the DB to check for revoked tokens and banned users', 0);
            }
            $lastCharacterOfJti = substr(strval($this->tokenClaims('jti')), -1);
            // clean out revoked token records if the UTC unix time ends in '0'
            if (0 == (intval($lastCharacterOfJti))) {
                $this->revocationTableCleanup($utcTimeNow);
            }
            if (!isset($unpackedTokenPayload('sub'))) {
                throw new RuntimeException("Subject standard claim not set to check ban status");
            }
            // ToDo: fix bind statement
            $stmt = $dbh->prepare("SELECT * FROM revoked_ehjwt where sub = ?");
            $stmt->bindParam(1, $unpackedTokenPayload('sub'));
            // get records for this sub
            if ($stmt->execute()) {
                while ($row = $stmt->fetch()) {
                    if ($row('jti') == 0 && $row('exp') > $utcTimeNow) {
                        // user is under an unexpired ban condition
                        return false;
                    }
                    if ($row('jti') == $unpackedTokenPayload('jti')) {
                        // token is revoked
                        return false;
                    }
                    // remove records for expired tokens to keep the table small and snappy
                    if ($row('exp') < $utcTimeNow) {
                        // deleteRevocation record
                        $this->deleteRecordFromRevocationTable($row('id'));
                    }
                }
            }
        }
        $this->createToken();
        $recreatedToken = $this->getToken();
        $recreatedTokenParts = explode('.', $recreatedToken);
        $recreatedTokenSignature = $recreatedTokenParts(2);
        if ($recreatedTokenSignature !== $tokenParts('2')) {
            // 'signature invalid, potential tampering
            return false;
        }
        // the token checks out!
        return true;
    }

    public function revocationTableCleanup(int $utcTimeStamp)
    {
        $dbh = $this->makeRevocationTableDatabaseConnection();
        $stmt = $dbh->prepare("DELETE FROM revoked_ehjwt WHERE `exp` <= $utcTimeStamp");
        $stmt->execute();
    }

    private function getTokenParts()
    {
        $tokenParts = explode('.', $this->token);
        if ($this->verifyThreeMembers($tokenParts)) {
            return $tokenParts;
        }
        throw new RuntimeException('Token does not contain three delimited sections', 0);
    }

    private function verifyThreeMembers(array $array)
    {
        if (3 !== count($array)) {
            // 'Incorrect quantity of segments'
            return false;
        }
        return true;
    }

    private function makeRevocationTableDatabaseConnection()
    {
        return new PDO($this->configurations('dsn'), $this->configurations('dbUser'), $this->configurations('dbPassword'), array(
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_NAMED
        ));
    }

    private function deleteRecordFromRevocationTable(string $recordId)
    {
        $dbh = $this->makeRevocationTableDatabaseConnection();
        $stmt = $dbh->prepare("DELETE FROM revoked_ehjwt WHERE id = ?");
        $stmt->bindParam(1, $recordId);
        return $stmt->execute();
    }

    public function reissueToken(string $tokenString, int $newUtcTimestampExpiration)
    {
        if ($this->loadToken($tokenString)) {
            $this->addOrUpdateJwtClaim('exp', $newUtcTimestampExpiration);
            $this->createToken();
        }
        return;
    }

    public function getToken()
    {
        return $this->token;
    }

    private function decodeTokenPayload($jwtPayload)
    {
        $decodedPayload = json_decode($this->base64UrlDecode($jwtPayload), true);
        if (0 !== json_last_error()) {
            throw new RuntimeException("JWT payload json_decode() error: " . json_last_error_msg(), 0);
        }
        return $decodedPayload;
    }

    public function getTokenClaims()
    {
        return $this->tokenClaims;
    }

    private function base64UrlEncode(string $unencodedString)
    {
        return rtrim(strtr(base64_encode($unencodedString), '+/', '-_'), '=');
    }

    private function base64UrlDecode(string $base64UrlEncodedString)
    {
        return base64_decode(str_pad(strtr($base64UrlEncodedString, '-_', '+/'), mb_strlen($base64UrlEncodedString) % 4, '=', STR_PAD_RIGHT));
    }

    private function makeHmacHash(string $base64UrlHeader, string $base64UrlClaims)
    {
        // sha256 is the only algorithm. sorry, not sorry.
        return hash_hmac('sha256', $base64UrlHeader . '.' . $base64UrlClaims, $this->configurations('jwtSecret'), true);
    }

    public function clearClaims()
    {
        $this->tokenClaims = ();
    }

    public function revokeToken()
    {
        // only add if the token is valid-- don't let imposters kill otherwise valid tokens
        if ($this->validateToken()) {
            $revocationExpiration = (int)$this->tokenClaims('exp') + 30;
            $this->writeRecordToRevocationTable($revocationExpiration);
        }
    }

    public function banUser(string $utcUnixTimestampBanExpiration)
    {
        $banExp = (int)$this->tokenClaims('exp') + 60;
        // insert jti of 0, sub... the userId to ban, and UTC Unix epoch of ban end
        $this->writeRecordToRevocationTable($utcUnixTimestampBanExpiration, true);
    }

    public function permabanUser()
    {
        // insert jti of 0, sub... the userId to ban, and UTC Unix epoch of ban end-- Tuesday after never
        $this->writeRecordToRevocationTable(4294967295, true);
    }

    public function unbanUser()
    {
        $this->deleteRecordsFromRevocationTable();
    }

    private function writeRecordToRevocationTable(int $exp, bool $ban = false)
    {
        $userBanJtiPlaceholder = 0;
        $dbh = $this->makeRevocationTableDatabaseConnection();
        $stmt = $dbh->prepare("INSERT INTO revoked_ehjwt (jti, sub, exp) VALUES (?, ?, ?)");
        $stmt->bindParam(1, $this->tokenClaims('jti'));
        if ($ban) {
            $stmt->bindParam(1, $userBanJtiPlaceholder);
        }
        $stmt->bindParam(2, $this->tokenClaims('sub'));
        $stmt->bindParam(3, $exp);

        return $stmt->execute();
    }

    private function deleteRecordsFromRevocationTable()
    {
        $dbh = $this->makeRevocationTableDatabaseConnection();
        $stmt = $dbh->prepare("DELETE FROM revoked_ehjwt WHERE sub = ? AND jti = 0");
        $stmt->bindParam(1, $this->tokenClaims('sub'));
        return $stmt->execute();
    }
    // ToDo: Provide access to a list of banned users
    public function retrieveBannedUsers()
    {
        $bannedUsers = array();

        $dbh = $this->makeRevocationTableDatabaseConnection();

        $stmt = $dbh->query('SELECT * FROM revoked_ehjwt WHERE `jti` = 0');

        if ($stmt->execute()) {
            while ($row = $stmt->fetch()) {
                $bannedUsers() = $row;
            }
            return $bannedUsers;
        }
    }}

linux – Tar –dereference with –listed-incremental not working as expected

I’m developing a simple incremental backup script, however the incremental part isn’t working. The used command is:

tar --create --atime-preserve=system --dereference --preserve-permissions --verbose --listed-incremental=$SNAR -f $TAR $TODAY

I have checked with stat <FILE> some of the files added after the initial full backup, and the result was

Access: 2020-11-09 08:18:32.464400659 +0200
Modify: 2019-10-09 17:40:18.000000000 +0300
Change: 2020-01-25 20:17:08.920323197 +0200

Access time seems alright, as that’s the time of the full backup yesterday, modify & change stamps are correct as well as those files are definitely not modified for almost a year, however tar continues to archive them.

The files are within a symlink’ed folder under $TODAY.

Does --dereference changes the Modify or Change stamps fooling tar that the file has been modified?

$ tar --version
tar (GNU tar) 1.30

How to run a dry test of a tar compression?

I want to run a dry test of a tar compression and print the entries on stdout without actually creating the tar.

So far I have tried:

// just spins
$ tar t -O Downloads
$ tar c -O Downloads
tar: Option -O is not permitted in mode -c

tar --help gives the following:

⋊> ~ tar --help                                                                                                                                                                                 08:06:22
tar(bsdtar): manipulate archive files
First option must be a mode specifier:
  -c Create  -r Add/Replace  -t List  -u Update  -x Extract
Common Options:
  -b #  Use # 512-byte records per I/O block
  -f   Location of archive
  -v    Verbose
  -w    Interactive
Create: tar -c (options) ( |  | @ | -C  )
  ,   add these items to archive
  -z, -j, -J, --lzma  Compress archive with gzip/bzip2/xz/lzma
  --format {ustar|pax|cpio|shar}  Select archive format
  --exclude   Skip files that match pattern
  -C   Change to  before processing remaining files
  @  Add entries from  to output
List: tar -t (options) ()
    If specified, list only entries that match
Extract: tar -x (options) ()
    If specified, extract only entries that match
  -k    Keep (don't overwrite) existing files
  -m    Don't restore modification times
  -O    Write entries to stdout, don't restore to disk
  -p    Restore permissions (including ACLs, owner, file flags)
bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.6

tar – How to open encrypted Apple DMGs so quickly?

On the remote drive, I have an encrypted .dmg and the same files in an encrypted gpg tar file.
The DMG opens in a few seconds, but to access the tar file, I must first decrypt it, in those 10 minutes, and then expand it, another 10 minutes.

How can Apple DMG be so fast? or where to find out more about how it works?

Hash files in a tar file

i have two *.tar files with similar content. I want to check which files are identical. Many files are large, so to compare hashes, you would have to extract each file from each tar and calculate the hash. Is there a way to hash files in a tar without having to extract it? Is there another way to compare every other file *.tar files?

linux – tar creates 0 byte files and issues denied permission errors

I work in a CentOS environment and configure perlbrew (App :: perlbrew / 0.87) locally. I've basically followed the steps here. I've set up perlbrew in a similar way in the past and without any problem, but now I encounter a strange problem. It should be noted that I was able to configure perlbrew and install perl locally on the same computer, the same environment, for another user.

The problem is that perlbrew is installed, but can not install any version of perl because after downloading the dist file, it can not extract the tar.gz file.

Here is some information about the installation. Perlbrew and cpanm seem to be in place and work perfectly.

-bash-4.1$ env | grep PERL
PERLBREW_SHELLRC_VERSION=0.87
PERLBREW_ROOT=/my/home/dir/perl5/perlbrew
PERLBREW_HOME=/my/home/dir/.perlbrew

-bash-4.1$ env | grep perl
OLDPWD=/my/home/dir/perl5/perlbrew
PERLBREW_ROOT=/my/home/dir/perl5/perlbrew
PATH=/my/home/dir/perl5/perlbrew/bin:/usr/local/bin:/bin:...
PWD=/my/home/dir/perl5/perlbrew/dists
PERLBREW_HOME=/my/home/dir/.perlbrew

-bash-4.1$ which perlbrew
~/perl5/perlbrew/bin/perlbrew


My .bash_profile contains only: 
source ~/perl5/perlbrew/etc/bashrc

-bash-4.1$ perlbrew available

   perl-5.31.6   
   perl-5.30.1   
   perl-5.28.2   
   perl-5.26.3   
   perl-5.24.4   
   ...

However, when I try to install it, tar errors start to appear.

-bash-4.1$ perlbrew install perl-5.30.1
tar: perl-5.30.1/.dir-locals.el: Cannot close: Permission denied
tar: perl-5.30.1/.dir-locals.el: Cannot utime: Permission denied
tar: perl-5.30.1/.lgtm.yml: Cannot close: Permission denied
tar: perl-5.30.1/.lgtm.yml: Cannot utime: Permission denied
...
it goes on and on for every file.

I think the key result here is:

Failed to extract /my/home/dir/perl5/perlbrew/dists/perl-5.30.1.tar.gz at /my/home/dir/perl5/perlbrew/bin/perlbrew line 1631

If I navigate to the place where perlbrew downloads the dist and tries to extract it manually, that fails.

-bash-4.1$ cd /my/home/dir/perl5/perlbrew/dists/
-bash-4.1$ ll
total 17308
drwxrwxrwx. 4 myUserID myGroup    11776 Dec  2 15:10 perl-5.30.1
-rwxrwxrwx. 1 myUserID myGroup 17712574 Nov 25 14:46 perl-5.30.1.tar.gz

-bash-4.1$ tar -xvf perl-5.30.1.tar.gz 
perl-5.30.1/
perl-5.30.1/.dir-locals.el
tar: perl-5.30.1/.dir-locals.el: Cannot close: Permission denied
tar: perl-5.30.1/.dir-locals.el: Cannot utime: Permission denied
perl-5.30.1/.lgtm.yml
tar: perl-5.30.1/.lgtm.yml: Cannot close: Permission denied
tar: perl-5.30.1/.lgtm.yml: Cannot utime: Permission denied
perl-5.30.1/.metaconf-exclusions.txt


The perl-5.30.1 directory is created and the files are created but they are not really extracted. It's just full of 0kb files where everything should be.

I've tried tar by creating archives from files that I create, compressing, decompressing, etc., everything seems to work well. All files belong to my user / group, so I do not understand why I can not extract this file.

Does anyone know what could be the cause of this behavior?

EDIT: It was done on a different machine configured in the same way!
I want to note again that I managed to install on a different user using the same method on the same computer and did not encounter this problem.

One user, @DavidMitchell, commented on the additional permissions indicated by ls -lZ that could affect things. Note that I'm using SGE on this machine and I need qlogin to handle most tasks.

Before and after qlogins:

In the perl/dist folder before qlogin.
-bash-4.1$ ls -lZ
-rwxrwxrwx. myUser myGroup system_u:object_r:nfs_t:s0       perl-5.30.1.tar.gz

AFTER qlogin
-bash-4.2$ ls -lZ
-rwxrwxrwx myUser MyGroup ?                                perl-5.30.1.tar.gz

So, there is one? there, then it's interesting. I've checked on another machine and another user with a successful installation and it seems to show the same thing, so maybe that's not the problem. Will continue to deepen the question, appreciate any additional advice!

dpkg does not work with the installation of termux ubuntu, returns the errors tar and leaves with the error code 1

I've tried using Termux to install Ubuntu on ChromeOS without developer mode or root privileges and I've managed so far. I've accessed an ubuntu shell since termux but dpkg returns this error for any package, making the system useless. This is the release of "apt install nano"

root @ localhost: ~ # apt install nano

Reading package lists … Done

Build a dependency tree

Reading status information … Done

Suggested packages:

to spell

The following NEW packages will be installed:

nano

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Need to get 243 KB of archives.

After this operation, 823 KB of additional disk space will be used.

Get: 1 http://archive.ubuntu.com/ubuntu bionic / hand i386 nano i386 2.9.3-2 (243 kB)

Recovered 243 KB in 1s (198 KB)

debconf: delay configuration of the package because apt-utils is not installed

E: Startup configuration failed via TCSAFLUSH for stdin! – tcsetattr (13: permission denied)

dpkg-deb: unrecoverable fatal error, dropping:

wait for the subprocess tar failed: error unknown 512

dpkg: archive during error handling /var/cache/apt/archives/nano_2.9.3-2_i386.deb (–unpack):

dpkg-deb – the control subprocess returned the error output status 2

Errors were encountered during treatment:

/var/cache/apt/archives/nano_2.9.3-2_i386.deb

tar:.: Can not mkdir: No file or directory of this type

tar: ./conffiles: not open: no such file or directory

tar: ./control: Can not open: no such file or directory

tar: ./md5sums: Can not open: No file or directory of this type

tar: ./postinst: can not open: no such file or directory

tar: ./prerm: Can not open: No file or directory of this type

tar: Output with failure status due to previous errors

E: The / usr / bin / dpkg subprocess returned an error code (1)