Solved pkg stopped working

Hello all,

I wonder if someone could help me understand why pkg(8) stopped working on my FreeBSD 10.1 system.

If I do a search, nothings get returned
Code:
root@garfield:~ # pkg search nginx
root@garfield:~ # pkg search mariadb
root@garfield:~ # pkg search tmux
root@garfield:~ # pkg search sudo
If I try to install something, nothing happen
Code:
root@garfiled:~ # pkg install sudo
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
pkg: No packages available to install matching 'sudo' have been found in the repositories
I did restart the server but nothing changed
root@garfield:~ # freebsd-version
Code:
10.1-RELEASE-p13
 
Double check /var/db/pkg and in particular check for the local.sqlite file in that directory. When that file is gone or inaccessible then you'll get the situation which you described above:

Code:
Enter full pathname or shell or RETURN for /bin/sh:
Cannot read termcap database;
using dumb terminal settings.
# mount /usr
# pkg info | wc -l
          0
# pkg info
# mount /var
pkg info | wc -l
          3
 
Hi ShelLuser
root@garfield:/var/db/pkg # ll
Code:
total 9308
-rw-r--r--  1 root  wheel  246 Jul  9 14:49 FreeBSD.meta
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 ca_root_nss-3.19/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 cmake-3.1.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 cmake-modules-3.1.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 curl-7.42.1/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 dev86-0.16.20/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 dialog4ports-0.1.5_2/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 expat-2.1.0_2/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 gcc-ecj-4.5/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 gettext-runtime-0.19.4/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 gettext-tools-0.19.4/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 indexinfo-0.2.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 libffi-3.2.1/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 libiconv-1.14_8/
-rw-r--r--  1 root  wheel  5611520 Jul  9 14:58 local.sqlite
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 lzo2-2.09/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 perl5.18-5.18.4_14/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 pixman-0.32.6_1/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 pkg-1.5.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 pkgconf-0.9.11/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 portmaster-3.17.7/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-Babel-1.3_2/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-Jinja2-2.7.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-MarkupSafe-0.23/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-docutils-0.12/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-pygments-2.0.2/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-pytz-2014.10,1/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-setuptools27-5.5.1_1/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 py27-sphinx-1.2.3/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 python27-2.7.9_1/
-rw-r--r--  1 root  wheel  58368 Jul  9 14:49 repo-FreeBSD.sqlite
-r--r--r--  1 root  wheel  3626588 Jul  9 03:05 vuln.xml
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 xorg-macros-1.19.0/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 yajl-2.1.0/
drwxr-xr-x  2 root  wheel  512 Jun 12 10:14 zip-3.0_1/
It look as everything is still there.
I also noticed for running the command su - I am no longer prompt for my password....

Should I be worried that the server has been compromise or am I over reacting?
 
I also noticed for running the command su - I am no longer prompt for my password....

Should I be worried that the server has been compromise or am I over reacting?

This is certainly cause for concern because that shouldn't happen in the default configuration. Have you set any custom authentication options in /etc/pam.d/su? What if you login directly as root on the console, are you asked for password? Is there a password set for root in /etc/master.passwd?
 
A server reboot seen to have solved the root password problem... Could be user error.
But pkg is still not working.

I compare the local.sqlite file permission and it seem ok to me.

Any other suggestion please?
 
To be honest the $ su - command not asking for a password and then starting to do so after a reboot still puzzles me, that's definitely not normal behavior.
 
To be honest the $ su - command not asking for a password and then starting to do so after a reboot still puzzles me, that's definitely not normal behavior.

Yes it does puzzle me as well but I haven't got the skills/knowledge to see if something has been comprimsed. I use ssh via public/private key and no password is allowed, root login is not allowed. Not sure how the system could be hacked. No web server running on it as of yet.
 
ShelLuser
I thought, I know that I realized why I wasn't prompt for the password. Looking at the history, I was login as admin user and then to su. Whilst I was login as su, I ran su admin , to login as admin again. Then when I typed su - when login as admin, it took me back to su ...

Hope this is clear enough for you to understand.
 
Back
Top