all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Doing Linux admin work with Emacs
       [not found] <70fd06bf-4566-4274-9381-ee569700cabd@n40g2000vbb.googlegroups.com>
@ 2010-10-13 12:12 ` Richard Riley
  2010-10-13 12:19 ` Pascal J. Bourguignon
  2010-10-13 21:20 ` Tim X
  2 siblings, 0 replies; 11+ messages in thread
From: Richard Riley @ 2010-10-13 12:12 UTC (permalink / raw
  To: help-gnu-emacs

bebop52 <gruenderteam.berlin@googlemail.com> writes:


> Hello,
> I think it's very nice to use emacs as "operating system" on top of
> linux (Ubuntu Lucid 10.0.4 in my case).  Especially dired is a
> wonderful tool in my eyes.
>
> When I start Gnu Emacs 23.1.1 with "myUser$ sudo emacs" (with myUser
> having admin rights)  I can do everything I want, since Emacs acts as
> root-user.  Which is very comfortable, but has a few negative side-
> effects:
>
> a) It means any new files/folders have owner and group 'root', but
> should have owner 'myUser' and group 'myUsersGroup'.
>
> b) Furthermore, many programs put some files or folders in the active
> users home directory during installation. For example maven puts its
> repo under  ~/.m2/repository/. My maven repository ended up under
> root/.m2/repository/, because emacs acted as root user, so that was
> the home directory.
>
> c) Isn't it very dangerous to do websurfing with w3m after starting
> emacs with "sudo emacs"? Any malware could potentially act as root
> user, if there are security wholes in w3m or emacs. But when I do
> admin work, I always have to google some stuff and end up in the web.
>
> On the other hand, if I do "myUser$ emacs" (with myUser having admin
> rights), without sudo, I can do admin work from the eshell using sudo
> when necessary. But what about dired, for example? How can I give
> emacs dired temporarily and in a controlled way admin rights (via
> sudo) while running it as 'myUser' and not as 'root'?
>
> I'm still looking for a decent workflow that enables me to open emacs
> in the morning via xterm or gnome and stay in emacs all day, do the
> admin/filesystem stuff as admin (but often via dired, if possible),
> work as a standard user with sudo rights when writing or programming,
> and surfing the web as a limited user without admin rights and with
> little security risks. And being able to swich effortlessly between
> the different roles.
>
> Thanks for any help from wiser minds to a relative beginner in the
> linux/emacs universe
> t.
>

The first thing I would say is this : do not run emacs as root for your
day long session. It's asking for trouble.

What admin tasks are you doing so frequently that you feel you need an
editor with root rights all the time?

There are various ways to open files in emacs as root. Google can
help. One such is:

,----
|   (defun find-alternative-file-with-sudo ()
|       "Open current buffer as root!"
|       (interactive)
|       (when buffer-file-name
|         (find-alternate-file
|          (concat "/sudo:root@localhost:"
|                  buffer-file-name))))
| 
|     (global-set-key (kbd "C-x C-r") 'find-alternative-file-with-sudo)
`----


The odd time you need to be root with dired? open a shell and su or run another
short lived emacs instance for that bit of stuff you want to do.

It is simple too dangerous to be running emacs as root all day long IMO
but your tastes might vary.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
       [not found] <70fd06bf-4566-4274-9381-ee569700cabd@n40g2000vbb.googlegroups.com>
  2010-10-13 12:12 ` Doing Linux admin work with Emacs Richard Riley
@ 2010-10-13 12:19 ` Pascal J. Bourguignon
  2010-10-14  2:34   ` Barry Margolin
  2010-10-13 21:20 ` Tim X
  2 siblings, 1 reply; 11+ messages in thread
From: Pascal J. Bourguignon @ 2010-10-13 12:19 UTC (permalink / raw
  To: help-gnu-emacs

bebop52 <gruenderteam.berlin@googlemail.com> writes:

> Hello,
> I think it's very nice to use emacs as "operating system" on top of
> linux (Ubuntu Lucid 10.0.4 in my case).  Especially dired is a
> wonderful tool in my eyes.
>
> When I start Gnu Emacs 23.1.1 with "myUser$ sudo emacs" (with myUser
> having admin rights)  I can do everything I want, since Emacs acts as
> root-user.  Which is very comfortable, but has a few negative side-
> effects:
>
> a) It means any new files/folders have owner and group 'root', but
> should have owner 'myUser' and group 'myUsersGroup'.
>
> b) Furthermore, many programs put some files or folders in the active
> users home directory during installation. For example maven puts its
> repo under  ~/.m2/repository/. My maven repository ended up under
> root/.m2/repository/, because emacs acted as root user, so that was
> the home directory.
>
> c) Isn't it very dangerous to do websurfing with w3m after starting
> emacs with "sudo emacs"? Any malware could potentially act as root
> user, if there are security wholes in w3m or emacs. But when I do
> admin work, I always have to google some stuff and end up in the web.

Indeed.  You should not do user stuff as root.  It's too easy to make a
mistake or to trip by some malware.


> On the other hand, if I do "myUser$ emacs" (with myUser having admin
> rights), without sudo, I can do admin work from the eshell using sudo
> when necessary. But what about dired, for example? How can I give
> emacs dired temporarily and in a controlled way admin rights (via
> sudo) while running it as 'myUser' and not as 'root'?

You can still open files as root with a user emacs, using tramp.

C-x C-f /root@localhost:/etc/hosts RET

Notice also that when you run a shell command with M-! or M-| from a
tramp buffer, the command is actually sent to the remote, ie. to the
root account in this case.




There's one problem when launching a command with sudo in M-x shell: you
cannot kill it with emacs C-c C-c, since emacs runs as a normal user, it
cannot kill the sudo'ed process.

For this reason, I usually still keep an xterm with screen, and in one
of the screens, I su to root, and from here, I launch an emacs (on X).
When I have a lot of root stuff to do (eg. install new packages, edit
configuration files), I go to this root emacs (my .emacs sets it in a
different color theme, with lots of reds, so that I don't forget to
switch back to my user emacs when I'm done with root stuff).

There's one inconvenient with this setup: my console has always a few
root shells available, so it should be in a secure environment.  If
there are people you don't trust root around you, you cannot leave your
console unattended.  On the other hand, it also has one advantage.  In
case of big botch up of your system you still have a couple of root
shells which can help you save the day, even if the botching up would
prevent root to log in (but this should not occur often, once or twice a
life time, I hope).  Last time it helped, was when I tried to debug a
script containing a: 

    rm -rf $dir/$subdir

command, as root...  Better write it as:

    [ "$dir/$subdir" = "/" ] || rm -rf "$dir/$subdir"


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
       [not found] <70fd06bf-4566-4274-9381-ee569700cabd@n40g2000vbb.googlegroups.com>
  2010-10-13 12:12 ` Doing Linux admin work with Emacs Richard Riley
  2010-10-13 12:19 ` Pascal J. Bourguignon
@ 2010-10-13 21:20 ` Tim X
  2 siblings, 0 replies; 11+ messages in thread
From: Tim X @ 2010-10-13 21:20 UTC (permalink / raw
  To: help-gnu-emacs

bebop52 <gruenderteam.berlin@googlemail.com> writes:

> Hello,
> I think it's very nice to use emacs as "operating system" on top of
> linux (Ubuntu Lucid 10.0.4 in my case).  Especially dired is a
> wonderful tool in my eyes.
>
> When I start Gnu Emacs 23.1.1 with "myUser$ sudo emacs" (with myUser
> having admin rights)  I can do everything I want, since Emacs acts as
> root-user.  Which is very comfortable, but has a few negative side-
> effects:
>
> a) It means any new files/folders have owner and group 'root', but
> should have owner 'myUser' and group 'myUsersGroup'.
>
> b) Furthermore, many programs put some files or folders in the active
> users home directory during installation. For example maven puts its
> repo under  ~/.m2/repository/. My maven repository ended up under
> root/.m2/repository/, because emacs acted as root user, so that was
> the home directory.
>
> c) Isn't it very dangerous to do websurfing with w3m after starting
> emacs with "sudo emacs"? Any malware could potentially act as root
> user, if there are security wholes in w3m or emacs. But when I do
> admin work, I always have to google some stuff and end up in the web.
>
> On the other hand, if I do "myUser$ emacs" (with myUser having admin
> rights), without sudo, I can do admin work from the eshell using sudo
> when necessary. But what about dired, for example? How can I give
> emacs dired temporarily and in a controlled way admin rights (via
> sudo) while running it as 'myUser' and not as 'root'?
>
> I'm still looking for a decent workflow that enables me to open emacs
> in the morning via xterm or gnome and stay in emacs all day, do the
> admin/filesystem stuff as admin (but often via dired, if possible),
> work as a standard user with sudo rights when writing or programming,
> and surfing the web as a limited user without admin rights and with
> little security risks. And being able to swich effortlessly between
> the different roles.
>
> Thanks for any help from wiser minds to a relative beginner in the
> linux/emacs universe
> t.
>

The solution I believe your looking for is tramp. 

Run emacs as a normal user without any special admin privs. Then, when
you need to edit a file as root, use the tramp sudo or su methods to
open the file (see the tramp manual).

Running emacs as root is a very bad idea. 

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-13 12:19 ` Pascal J. Bourguignon
@ 2010-10-14  2:34   ` Barry Margolin
  2010-10-14  8:17     ` Olivier Sirven
  2010-10-14 10:17     ` Miles Bader
  0 siblings, 2 replies; 11+ messages in thread
From: Barry Margolin @ 2010-10-14  2:34 UTC (permalink / raw
  To: help-gnu-emacs

In article <8762x6jnde.fsf@kuiper.lan.informatimago.com>,
 pjb@informatimago.com (Pascal J. Bourguignon) wrote:

> There's one problem when launching a command with sudo in M-x shell: you
> cannot kill it with emacs C-c C-c, since emacs runs as a normal user, it
> cannot kill the sudo'ed process.

You can kill it by typing C-q C-c RET.  This sends a literal C-c to the 
shell's terminal, instead of Emacs sending a signal to the process.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14  2:34   ` Barry Margolin
@ 2010-10-14  8:17     ` Olivier Sirven
  2010-10-14 10:17     ` Miles Bader
  1 sibling, 0 replies; 11+ messages in thread
From: Olivier Sirven @ 2010-10-14  8:17 UTC (permalink / raw
  To: help-gnu-emacs

On 2010-10-14 04:34:20, Barry Margolin <barmar@alum.mit.edu> wrote:
> You can kill it by typing C-q C-c RET.  This sends a literal C-c to the 
> shell's terminal, instead of Emacs sending a signal to the process.

Thanks for the tip!

--
Olivier


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14  2:34   ` Barry Margolin
  2010-10-14  8:17     ` Olivier Sirven
@ 2010-10-14 10:17     ` Miles Bader
  2010-10-14 12:46       ` bebop52
  2010-10-15  1:50       ` Barry Margolin
  1 sibling, 2 replies; 11+ messages in thread
From: Miles Bader @ 2010-10-14 10:17 UTC (permalink / raw
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:
>> There's one problem when launching a command with sudo in M-x shell: you
>> cannot kill it with emacs C-c C-c, since emacs runs as a normal user, it
>> cannot kill the sudo'ed process.
>
> You can kill it by typing C-q C-c RET.  This sends a literal C-c to the 
> shell's terminal, instead of Emacs sending a signal to the process.

Hmm, by if Emacs was configured correctly, "C-c C-c" should handle this
case properly though -- it uses (interrupt-subprocess nil t):

   (interrupt-process &optional PROCESS CURRENT-GROUP)

   Interrupt process PROCESS.
   PROCESS may be a process, a buffer, or the name of a process or buffer.
   No arg or nil means current buffer's process.
   Second arg CURRENT-GROUP non-nil means send signal to
   the current process-group of the process's controlling terminal
   rather than to the process's own process group.
   If the process is a shell, this means interrupt current subjob
   rather than the shell.

... which basically interrupts the "terminal" (pty) rather than the
process itself.

Also, it Works For Me :)

-miles

-- 
Patience, n. A minor form of despair, disguised as a virtue.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14 10:17     ` Miles Bader
@ 2010-10-14 12:46       ` bebop52
  2010-10-14 15:00         ` Pascal J. Bourguignon
  2010-10-14 21:42         ` Tim X
  2010-10-15  1:50       ` Barry Margolin
  1 sibling, 2 replies; 11+ messages in thread
From: bebop52 @ 2010-10-14 12:46 UTC (permalink / raw
  To: help-gnu-emacs

Thanks to everybody for the detailled and helpful information. I'm
going to quit doing regular work as root, thats for sure. I like both
ideas, using tramp or having a second emacs window (with different
colours) used only for admin work - I have to give it a try.
So I really do need only one user instead of my two different users
that complicate my life tremendously.

I'm still a bit confused about the admin rights:
- is it common and secure to surf the web as a non-root standard user
WITH system administration rights?
- are giving a user admin rights and giving him sudo-rights two
different, independent concepts? I now have two users with admin
rights, but /etc/sudoers  has only one uncommented line: "root
ALL=(ALL) ALL" and /etc/sudoers.d/ is empty.
- did I get it right that the option to use tramp sudo/su is available
to standard user WITHOUT system administration rights too?

When I get this user stuff straight I would only need to find a (easy)
way how to connect to alice dsl from an xterm session, then I wouldn't
need no gnome desktop anymore, just xterm and emacs. But thats
probably another topic. (using gnome it's just one click on the
network-manager-applet and I'm connected. I wish there would be just
one command in an xterm window to achieve the same).


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14 12:46       ` bebop52
@ 2010-10-14 15:00         ` Pascal J. Bourguignon
  2010-10-14 21:42         ` Tim X
  1 sibling, 0 replies; 11+ messages in thread
From: Pascal J. Bourguignon @ 2010-10-14 15:00 UTC (permalink / raw
  To: help-gnu-emacs

bebop52 <gruenderteam.berlin@googlemail.com> writes:

> Thanks to everybody for the detailled and helpful information. I'm
> going to quit doing regular work as root, thats for sure. I like both
> ideas, using tramp or having a second emacs window (with different
> colours) used only for admin work - I have to give it a try.
> So I really do need only one user instead of my two different users
> that complicate my life tremendously.
>
> I'm still a bit confused about the admin rights:
> - is it common and secure to surf the web as a non-root standard user
> WITH system administration rights?

That would depend on the meaning of "administration rights".  That's the
problem with GUI, they set you far apart from the semantics.

Classically administrators were users that were in the wheel or root
group (gid = 0 in /etc/group).  This allowed them to access files
assigned to the wheel group, and some programs like su would filter out
users not in that group.

Nowadays, sudo is favored, and an administrator would have to be in
/etc/sudoers.


But at a GUI level, there could also be another kind of management of
"administrators", with an independent database and gateway tools.


> - are giving a user admin rights and giving him sudo-rights two
> different, independent concepts? 

Good question.


> I now have two users with admin
> rights, but /etc/sudoers  has only one uncommented line: "root
> ALL=(ALL) ALL" and /etc/sudoers.d/ is empty.

When I want to be able to use sudo, I do:

su - bash -c "echo 'pjb ALL=(ALL) ALL' >> /etc/sudoers"

Perhaps there's other ways to configure sudo. Reading the documentation
would be good.



> - did I get it right that the option to use tramp sudo/su is available
> to standard user WITHOUT system administration rights too?

su yes, sudo no.  sudo checks that the calling user has the right to use
sudo, so that the calling user may use the su account only giving his
own password.


su only check the password of the su user, which the normal user has to
know, whoever he is.  su is similar to ssh root@localhost (but ssh
itself can be configured to prevent root connection, or to prevent
connecting to the root account automatically with the authorized_keys
features).



> When I get this user stuff straight I would only need to find a (easy)
> way how to connect to alice dsl from an xterm session, then I wouldn't
> need no gnome desktop anymore, just xterm and emacs.

Notice that emacs also contains a terminal emulator similar to xterm:

M-x term RET

In term, most keys are sent to the terminal.  Use C-c b  to switch to
another buffer and go on with normal emacs life.

So theorically, you could also avoid xterm.


To connect to a router, in general you can use the web (but they often
require javascript or java, so that rules out emacs-w3m), or telnet or
ssh.

Try out:

M-x shell RET 
telnet $ip_of_your_router  RET

To get out of telnet, type C-] q RET



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14 12:46       ` bebop52
  2010-10-14 15:00         ` Pascal J. Bourguignon
@ 2010-10-14 21:42         ` Tim X
  1 sibling, 0 replies; 11+ messages in thread
From: Tim X @ 2010-10-14 21:42 UTC (permalink / raw
  To: help-gnu-emacs

bebop52 <gruenderteam.berlin@googlemail.com> writes:
[snip]
>
> I'm still a bit confused about the admin rights:
> - is it common and secure to surf the web as a non-root standard user
> WITH system administration rights?

The concepts under Linux are a bit different from Windows and other
systems. Normally, you do everything you can with just a normal user.
That user frequently has no additional administration rights except
perhaps the ability to read log files and the ability to run su or sudo
(sudo is generally preferred these days as it will provide more fine
grained control and the user does not need to know the root password). 

The general scheme for controlling access under Linux is based on the
concept of uid and gid (user ID and group ID). Every user has one uid
and at least one gid. However, you can have multiple gids (i..e be a
member of multiple groups). A common approach under Linux is to have
groups representing various privileges, such as access to the sound
devices, cdrom, usb, ppp/modem administration/operator etc. It is
difficult to give specific details as different Linux distributions
handle the problem in slightly different ways.

The rule of thumb is always run with the minimal privileges you need to
do the job.

The basic approach you should use is to do everything as a normal user,
initially with no other privileges than those needed to run sudo. This
may mean you need to be in an 'administrator' group. If you find you
cannot access something, such as the cdrom drive or modem or printer,
check your distribution documentation. You may need to have your user
added to a specific group to access a resource. 

In general, for surfing the web, no additional privileges are required,
except perhaps the ability to bring up the network interface.

> - are giving a user admin rights and giving him sudo-rights two
> different, independent concepts? I now have two users with admin
> rights, but /etc/sudoers  has only one uncommented line: "root
> ALL=(ALL) ALL" and /etc/sudoers.d/ is empty.
> - did I get it right that the option to use tramp sudo/su is available
> to standard user WITHOUT system administration rights too?

The best way to know this is try it out. Create a test account with no
privs other than what they get by default and see. 

sudo is quite powerful and huas numerous options for controlling how it
works. For example, on my system, I have the line 

%admin ALL=(ALL) ALL

which restricts normal users to having to be in the admin group to use
sudo.

>
> When I get this user stuff straight I would only need to find a (easy)
> way how to connect to alice dsl from an xterm session, then I wouldn't
> need no gnome desktop anymore, just xterm and emacs. But thats
> probably another topic. (using gnome it's just one click on the
> network-manager-applet and I'm connected. I wish there would be just
> one command in an xterm window to achieve the same).

There likely is. You need to read your distro docs. A major difference
with Linux over Windows is that often GUIs, such as gnomes
network-manager, are really just a graphical wrapper over various text
config files and command line programs (I'm simplifying slightly). One
of the reasons Unix/Linux has been so successful in the server space
compared to Windows (though the gap has narrowed in recent years) is
that it was much easier to write shell scripts to pretty much do
anything that could be done with the GUI. I still remember my
frustrations years ago, when having to use NT at how difficult it was to
automate some things I could easily do with a script under Unix. Windows
is much more GUI oriented - the GUI is first and the scripting comes
second. Unix, I suspect due to its history, was command line first and
GUI later. 

Tim

-- 
tcross (at) rapttech dot com dot au


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-14 10:17     ` Miles Bader
  2010-10-14 12:46       ` bebop52
@ 2010-10-15  1:50       ` Barry Margolin
  2010-10-16  3:16         ` Miles Bader
  1 sibling, 1 reply; 11+ messages in thread
From: Barry Margolin @ 2010-10-15  1:50 UTC (permalink / raw
  To: help-gnu-emacs

In article <buohbgpaxjq.fsf@dhlpc061.dev.necel.com>,
 Miles Bader <miles@gnu.org> wrote:

> Barry Margolin <barmar@alum.mit.edu> writes:
> >> There's one problem when launching a command with sudo in M-x shell: you
> >> cannot kill it with emacs C-c C-c, since emacs runs as a normal user, it
> >> cannot kill the sudo'ed process.
> >
> > You can kill it by typing C-q C-c RET.  This sends a literal C-c to the 
> > shell's terminal, instead of Emacs sending a signal to the process.
> 
> Hmm, by if Emacs was configured correctly, "C-c C-c" should handle this

What do you mean by "configured correctly"?  Is this an option the user 
can configure?  Or are you referring to a compile-time setting?

> case properly though -- it uses (interrupt-subprocess nil t):
> 
>    (interrupt-process &optional PROCESS CURRENT-GROUP)
> 
>    Interrupt process PROCESS.
>    PROCESS may be a process, a buffer, or the name of a process or buffer.
>    No arg or nil means current buffer's process.
>    Second arg CURRENT-GROUP non-nil means send signal to
>    the current process-group of the process's controlling terminal
>    rather than to the process's own process group.
>    If the process is a shell, this means interrupt current subjob
>    rather than the shell.
> 
> ... which basically interrupts the "terminal" (pty) rather than the
> process itself.

Where does it say that?  It repeatedly says that it sends the signal to 
a process or process group, it never says anything about sending a 
signal to the pty.  But ordinary users aren't allowed to send signals to 
processes owned by other users.  Typing C-c gets around this, because 
the terminal driver interprets this, and it's able to send signals to 
any process connected to the terminal (since it's in the kernel, it 
could actually send signals to any process, but it never would).

If there were an ioctl on the master side of a pty that sends a signal 
to the process group connected to the slave side, that would solve the 
problem.  But I checked my pty(4) man page and didn't see anything like 
this.

> Also, it Works For Me :)

It's never worked for me with sudo processes.

I'm running the Carbon Emacs build of Emacs 22.2, but I had the same 
problem years ago on Solaris.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Doing Linux admin work with Emacs
  2010-10-15  1:50       ` Barry Margolin
@ 2010-10-16  3:16         ` Miles Bader
  0 siblings, 0 replies; 11+ messages in thread
From: Miles Bader @ 2010-10-16  3:16 UTC (permalink / raw
  To: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:
>> Hmm, by if Emacs was configured correctly, "C-c C-c" should handle this
>
> What do you mean by "configured correctly"?  Is this an option the user 
> can configure?  Or are you referring to a compile-time setting?

Well, both compile-time settings and run-time settings.

Of course, the handling of ptys/ioctls/etc is very system-dependent,
and there's tons of different compile-time-selected code-paths in
Emacs to handle them on different types of systems -- but configure
should get that right mostly.

At runtime, the only configuration I'm aware of is whether pipes or
ptys are used for subprocesses (via the `process-connection-type'
variable, defaulting to t [ptys] on most non-Windows systems I think).
If Emacs uses pipes for subshells, things generally work less nicely.

> Where does it say that?  It repeatedly says that it sends the signal to 
> a process or process group, it never says anything about sending a 
> signal to the pty.  But ordinary users aren't allowed to send signals to 
> processes owned by other users.  Typing C-c gets around this, because 
> the terminal driver interprets this, and it's able to send signals to 
> any process connected to the terminal (since it's in the kernel, it 
> could actually send signals to any process, but it never would).

On linux, at least, Emacs just sends the appropriate interrupt character
to the pty master as if the user had typed it.

So if the user types "C-c C-c" in a shell buffer, comint calls
(interrupt-process ...), which in process.c gets turned into
process_send_signal (..., SIGINT, ...) -- but then process_send_signal
notices it's a pty and SIGINT, and turns around and just sends "^C" to
the pty as input!

This isn't pretty, and has problems of its own, but it does generally
handle the "interrupting a sudo'd command in a shell buffer" case as
users expect.

> I'm running the Carbon Emacs build of Emacs 22.2, but I had the same 
> problem years ago on Solaris.

Dunno if it's broken on 22.x (haven't used that for ages), but I
have the vague impression that things have basically behaved the
same way for a long time...

-Miles

-- 
Youth, n. The Period of Possibility, when Archimedes finds a fulcrum,
Cassandra has a following and seven cities compete for the honor of endowing a
living Homer.


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-10-16  3:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <70fd06bf-4566-4274-9381-ee569700cabd@n40g2000vbb.googlegroups.com>
2010-10-13 12:12 ` Doing Linux admin work with Emacs Richard Riley
2010-10-13 12:19 ` Pascal J. Bourguignon
2010-10-14  2:34   ` Barry Margolin
2010-10-14  8:17     ` Olivier Sirven
2010-10-14 10:17     ` Miles Bader
2010-10-14 12:46       ` bebop52
2010-10-14 15:00         ` Pascal J. Bourguignon
2010-10-14 21:42         ` Tim X
2010-10-15  1:50       ` Barry Margolin
2010-10-16  3:16         ` Miles Bader
2010-10-13 21:20 ` Tim X

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.