1 |
On Wednesday, September 16, 2015 8:01:56 AM Alan McKinnon wrote: |
2 |
> On 16/09/2015 00:36, Fernando Rodriguez wrote: |
3 |
> > On Tuesday, September 15, 2015 10:25:15 PM Alan McKinnon wrote: |
4 |
> >> On 15/09/2015 22:09, james wrote: |
5 |
> >>> Hello, |
6 |
> >>> |
7 |
> >>> So looking at /etc/portage/repos.conf, it seems root.root owns these |
8 |
> >>> files; shouldn't it be portage.portage? and /usr/portage |
9 |
> >>> |
10 |
> >>> That got me thinking. Everywhere that portage operates or owns |
11 |
> >>> things, should the ownership not be portage.portage |
12 |
> >>> and what would the typical permissions be? |
13 |
> >> |
14 |
> >> Here, all of /etc/portage is root:root |
15 |
> >> The tree and all overlays are portage:portage |
16 |
> >> |
17 |
> >> You can make a local overlay owned by user you want, stuff you hack away |
18 |
> >> at yourself should probably be james:james or james:users |
19 |
> >> |
20 |
> >> Typically, permissions in /etc/portage are the usual 755 for dirs and |
21 |
> >> 644 for files |
22 |
> >> |
23 |
> >> I set overlays and the tree to be 2775 for dirs and 664 for files |
24 |
> >> |
25 |
> >>> |
26 |
> >>> Is there a master list I can look at? Surely root not own all |
27 |
> >>> these dirs, like /usr/portage/* ? My /usr/portage is root.root |
28 |
> >>> and 755 on permissions, is that right? |
29 |
> >> |
30 |
> >> Permissions should be what YOU need them to be on your computer. There's |
31 |
> >> a default, it's what portage makes them when you install stuff |
32 |
> >> |
33 |
> >>> |
34 |
> >>> If so, why? |
35 |
> >> |
36 |
> >> Only root should change the master config files in /etc, just like in |
37 |
> >> all other apps |
38 |
> >> IIRC emerge can drop privs to a user account, if that user is portage |
39 |
> >> then portage must own the files |
40 |
> > |
41 |
> > It is true that portage drops privileges to the portage account (unless |
42 |
the |
43 |
> > ebuild has RESTRICT="userpriv" or I think FEATURES="-userpriv" on |
44 |
make.conf) |
45 |
> > but it doesn't need to write to the portage tree except to the distfiles |
46 |
> > directory so I don't know of any reason to have everything owned by |
47 |
> > portage:portage if the perms are 755/644. |
48 |
> |
49 |
> portage also syncs the tree. For that it needs write perms. |
50 |
> |
51 |
> > |
52 |
> > Mine is owned by root:root because it got borked one time after a sync so |
53 |
I |
54 |
> > deleted it and copied from another box manually. The only problem I ever |
55 |
had |
56 |
> > is that a fetch failed, and I just chowned the distfiles dir to |
57 |
portage:portage |
58 |
> > to fix it. Only recently it was pointed to me on this list that it was |
59 |
supposed |
60 |
> > to be portage:portage. I never changed it back to portage:portage but I |
61 |
made a |
62 |
> > mental note not to forget about it in case of trouble, that way I'll learn |
63 |
why |
64 |
> > that's the default if/when something breaks :) Besides it offers some |
65 |
(limited) |
66 |
> > protection against an ebuild accidentally writing to your portage tree. |
67 |
> > |
68 |
> >>> |
69 |
> >>> In my /usr/local/portage and it's subdirs where I hack on many |
70 |
> >>> ebuild, portage.portage owns everything.....? |
71 |
> >> |
72 |
> >> Make your life easy, chaown that stuff to james |
73 |
> > |
74 |
> > I personally prefer root:root because I think it is more secure. If you |
75 |
let |
76 |
> > somebody use your account even for a minute s/he could modify an ebuild |
77 |
> > without a password to install whatever s/he wants next time you run an |
78 |
update. |
79 |
> |
80 |
> I'll argue that it's less secure. Giving someone else a gap to modify |
81 |
> your ebuilds when you accidentally leave the computer unlocked is a rare |
82 |
> event whereas you modifying your own ebuilds like james does is a common |
83 |
> event. |
84 |
> |
85 |
> If an overlay is root:root then he has to be root every time he works on |
86 |
> it. If he then commits that rare blunder of leaving the computer |
87 |
> unlocked, Murphy says he'll do it with a root shell open. |
88 |
|
89 |
I also have the habit of never opening root shells unless absolutely necessary |
90 |
(which is next to never) and when I do I'm very conscious about it so that |
91 |
won't be a problem for me. I do a lot of ebuild hacking and that does mean I |
92 |
type my password a lot but you get used to it. |
93 |
|
94 |
> While it is entirely possible to have a rogue colleague install a dodgy |
95 |
> ebuild, that attacker would have to know exactly what to install where |
96 |
> and would have to have the ebuild on hand to slip it in during the very |
97 |
> few minutes available. To my eye that's a very small window of |
98 |
> opportunity and needs a perfect storm to pull it off = vanishingly small |
99 |
> risk |
100 |
|
101 |
If that was my mission I just pick something that I know you run at startup |
102 |
like udev (I may pick something more trivial if possible to minimize the |
103 |
chance of you noticing). I'd bump the version and have the ebuild install my |
104 |
evil program along with it and add a few liner patch to fork() and execve() my |
105 |
program or just make my program a patch to the main prog. Then I'll put it on |
106 |
a webserver along with a script that does to work for me. Now I just need to |
107 |
run a single command to download and execute the script. |
108 |
|
109 |
So granted, it takes planning, and maybe some social engineering or other |
110 |
methods to get details about your system but once I get the chance it'll take |
111 |
only a few seconds and next time you update I'd have root access. |
112 |
|
113 |
-- |
114 |
Fernando Rodriguez |