apt-get 嘗試存取 ~/.config/git/

apt-get 嘗試存取 ~/.config/git/

使用套件管理器安裝新套件時,出現如下所示的權限錯誤。發生這種情況是因為/home是從另一台伺服器安裝的,但是為什麼首先apt-get 嘗試訪問?~/.config/git

(base) blk6@gho:~/$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libssl-doc
The following NEW packages will be installed:
  libssl-dev
0 upgraded, 1 newly installed, 0 to remove and 57 not upgraded.
Need to get 1,566 kB of archives.
After this operation, 7,846 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.5 [1,566 kB]
Fetched 1,566 kB in 3s (507 kB/s)       
warning: unable to access '/home/Users/blk6/.config/git/attributes': Permission denied
warning: unable to access '/home/Users/blk6/.config/git/ignore': Permission denied
Selecting previously unselected package libssl-dev:amd64.
(Reading database ... 219434 files and directories currently installed.)
Preparing to unpack .../libssl-dev_1.1.1-1ubuntu2.1~18.04.5_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.5) ...
Setting up libssl-dev:amd64 (1.1.1-1ubuntu2.1~18.04.5) ...
warning: unable to access '/home/Users/blk6/.config/git/ignore': Permission denied

答案1

我不知道為什麼你的套件管理器會嘗試呼叫 git,但你可以嘗試使用strace實用程式來弄清楚發生了什麼。 strace 追蹤系統調用,包括開啟檔案或執行程式的嘗試。

為了調查您的具體問題,我將嘗試找出其分叉子進程(-e execve)正在執行哪些命令( ):apt-get-f

sudo strace -f -e execve apt-get install ...

如果刪除該-e execve選項,則不會套用任何過濾器,從而導致輸出過長。若要讓 strace 將其輸出寫入文件,可以-o file.txt在命令之前使用該選項(例如strace -f -o file.txt apt install ...)。

您也可以用來-e execve -e file追蹤命令執行以及開啟或讀取檔案的嘗試。然後搜尋 git 指令的調用,並尋找該調用上方的行。也許這會揭示調用該命令的腳本名稱。

如果這還不夠,您可以考慮掃描/etc/apt/.也許您已將其配置為調用某些鉤子。尋找 git 呼叫的範例:

grep -nre git /etc/apt

如果沒有匹配,輸出將為空,否則顯示文件、行號和行內容。

相關內容