Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sippts: permissions / database / working directory #2336

Closed
noraj opened this issue May 9, 2019 · 4 comments
Closed

sippts: permissions / database / working directory #2336

noraj opened this issue May 9, 2019 · 4 comments

Comments

@noraj
Copy link
Contributor

noraj commented May 9, 2019

Bug description

$ sipscan
cp: cannot create regular file 'sippts.db': Permission denied
DBI connect('dbname=sippts.db','',...) failed: unable to open database file at sipscan.pl line 59.
unable to open database file at sipscan.pl line 59.

Troubleshooting:

$ which sipscan
/usr/bin/sipscan

$ head /usr/bin/sipscan
#!/bin/sh
cd /usr/share/sippts
exec perl sipscan.pl "${@}"

$ sed -n 59p /usr/share/sippts/sipscan.pl
my $db = DBI->connect("dbi:SQLite:dbname=$database","","") or die $DBI::errstr;

$ sed -n 47,48p /usr/share/sippts/sipscan.pl
my $database = "sippts.db";
my $database_empty = "sippts_empty.db";

$ sed -n 53,60p /usr/share/sippts/sipscan.pl
unless (-e $database || -e $database_empty) {
        die("Database $database not found\n\n");
}

system("cp $database_empty $database") if (! -e $database);

my $db = DBI->connect("dbi:SQLite:dbname=$database","","") or die $DBI::errstr;
my $hostsid = last_id();

The script has no permission to do cp sippts_empty.db sippts.db in the protected folder /usr/share/sippts/.

But we can't do something has the following for /usr/bin/sipscan because the whole script is made to find the db in the working directory.

#!/bin/sh
exec perl /usr/share/sippts/sipscan.pl "${@}"

So with this kind of wrapper it ends with

$ sipscan
Database sippts.db not found

Even if using -nodb the script will still look for the db in the first place.

The only way (without making upstream changes or without using root privilegies) is to copy an empty db in the working directory cp /usr/share/sippts/sippts_empty.db sippts.db.

So it is rather unhandy. Have we another way or do we need to call for an upstream fix?

@noraj
Copy link
Contributor Author

noraj commented May 9, 2019

@Pepelux
Copy link

Pepelux commented May 9, 2019

Hi Noraj

I've just update the scripts to create database file (and open connections) only if -db parameter is chosen. I don't know if there are other problems with permissions, for example when create TXT logs. On this case you can open another issue and I'll check it.

Commit. Pepelux/sippts@128520e

@noraj
Copy link
Contributor Author

noraj commented May 9, 2019

You're very welcome, we'll try that.

@Edu4rdSHL
Copy link
Contributor

Fixed via 37e39a9.

Thanks @noraj for reporting and thanks @Pepelux for fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants