Короче говоря, пользовательский файл wrapped-passphrase
имел неправильные разрешения (должно быть -rw------- user user
, было-rw------- root root
).
Выполнил команду ecryptfs-mount-private
(ввел пароль для входа в систему )с помощью strace
например:
strace -o /tmp/strace.log -e trace=file ecryptfs-mount-private
Содержание/tmp/strace.log
:
user@host:~$ sudo strace -o /tmp/strace.log -e trace=file ecryptfs-mount-private
[sudo] password for user:
Enter your login passphrase:
Inserted auth tok with sig [3ab5cd8e5f8c5acb] into the user session keyring
fopen: No such file or directory
user@host:~$ cat /tmp/strace.log
execve("/usr/bin/ecryptfs-mount-private", ["ecryptfs-mount-private"], [/* 13 vars */]) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
getcwd("/home/user", 4096) = 9
open("/usr/bin/ecryptfs-mount-private", O_RDONLY) = 3
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3872, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
stat("/home/user/.ecryptfs/wrapping-independent", 0x7fff65e61c30) = -1 ENOENT (No such file or directory)
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3873, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
stat("/home/user/.ecryptfs/wrapped-passphrase", {st_mode=S_IFREG|0600, st_size=58,...}) = 0
stat("/home/user/.ecryptfs/Private.sig", {st_mode=S_IFREG|0600, st_size=34,...}) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3874, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
stat("/usr/local/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory)
stat("/usr/local/bin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory)
stat("/usr/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory)
stat("/usr/bin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory)
stat("/sbin/stty", 0x7fff65e61c40) = -1 ENOENT (No such file or directory)
stat("/bin/stty", {st_mode=S_IFREG|0755, st_size=72496,...}) = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3875, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3876, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3877, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3878, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3879, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3880, si_uid=0, si_status=0, si_utime=68, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3881, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
+++ exited with 1 +++
Итак, мы видим, что информации недостаточно. Выполнил ту же команду (ввел пароль для входа ), но с флагом -f
для трассировки дочерних процессов и с использованием прав root :
sudo strace -o /tmp/strace2.log -f -e trace=file ecryptfs-mount-private`
Часть содержимого файла /tmp/strace2.log
:
...
3963 open("/root/.ecryptfsrc", O_RDONLY) = -1 ENOENT (No such file or directory)
3963 open("/home/user/.ecryptfs/wrapped-passphrase", O_RDONLY) = 3
...
3964 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
3964 open("/root/.ecryptfs/Private.mnt", O_RDONLY) = -1 ENOENT (No such file or directory)
3964 open("/dev/shm/ecryptfs-root-Private", O_RDWR|O_CREAT|O_NOFOLLOW, 0600) = 3
3964 open("/root/.ecryptfs/Private.sig", O_RDONLY) = -1 ENOENT (No such file or directory)
3964 +++ exited with 1 +++
3954 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3964, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
3954 +++ exited with 1 +++
Как мы видим, он не может найти файл Private.sig
из корня ; похоже, что его должен запускать пользователь, который зашифровал каталог, который мы пытаемся восстановить, а не запускать его в определенном каталоге.
В общем,Я выполнил эту команду (ввел пароль для входа )с правами пользователя:
strace -o /tmp/strace3.log -f -e trace=file ecryptfs-mount-private`
Часть содержимого файла /tmp/strace3.log
:
...
4137 open("/lib/x86_64-linux-gnu/libnss_nis.so.2", O_RDONLY|O_CLOEXEC) = 3
4137 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
4137 open("/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
4137 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
4137 open("/home/user/.ecryptfsrc", O_RDONLY) = -1 ENOENT (No such file or directory)
4137 open("/home/user/.ecryptfs/wrapped-passphrase", O_RDONLY) = -1 EACCES (Permission denied)
4137 open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 3
4137 +++ exited with 1 +++
4112 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4137, si_uid=1000, si_status=1, si_utime=0, si_stime=0} ---
...
Как мы видим, утилита ecryptfs-mount-private
не может получить доступ к пользовательскому wrapped-passphrase
файлу, что приводит к сообщению Отказано в доступе .
Проверено /home/user/.ecryptfs/wrapped-passphrase
права доступа к файлу, и они были:
-rw------- 1 root root
Изменен владелец этого файла через sudo chown user:user /home/user/.ecryptfs/wrapped-passphrase
на пользователя и повторно запущен выше(ecryptfs-mount-private
)команда без strace (введен пароль для входа в систему ), что привело к успешному сообщению:
INFO: Your private directory has been mounted.
INFO: To see this change in your current shell:
cd: /home/user
Использованиеawk
:
awk 'min[$1] == "" || $2 < min[$1] { min[$1] = $2 }
max[$1] == "" || $2 > max[$1] { max[$1] = $2 }
END { for (i in min) print i, min[i], max[i] }' file |
sort -rn
Запоминает максимальное и минимальное значения, связанные с первым столбцом в ассоциативных массивах max
и min
. Эти значения печатаются, когда все данные обработаны.
sort -rn
в конце обеспечивает сортировку вывода в порядке убывания.
С сортировкой входных данных как у вас:
$ awk '$1 != p{printf "%s%s",max,$0; p=$1} {max=OFS $2 ORS} END{printf "%s", max}' file
32 1 5
17 8 11
14 33 35