[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

C[ool] gnome-terminal wrapper



Hello,

I've spent some time rewriting a program I've called 'term' for opening gnome-terminal windows. It's just a wrapper, but does several things:

- uses correct options to use the factoryserver feature of gnome-terminal
- only uses the factory-server when the current working directory is the home directory (so when you type 'term' from a terminal while not in the home dir, a new instance is opened preserving the current uid and cwd). - adds a default geometry to make windows bigger (overridden by setting TERM_GEOMETRY env var)

and the reason I did the C rewrite:
- increases the resource limit for the number of open files. This requires a setuid-root program so I did it in C. Why increasing this resource limit? Because I frequently ran into a problem when a gnome-terminal factoryserver has many windows open (about 50 of them): it then runs into the debian default 1024 file limit and refuses to open new windows, eats 100% cpu and hangs exiting shells. (Don't ask me why it needs 20 filehandles per shell - lsof shows them all being fifo's.)

So here it is in it's full beauty (hey, it's C, so it may be 5 times longer than a shell or perl script):
http://pflanze.mine.nu/~chris/scripts/c_progs/term.c

Please note that the new rlimit setting will of course also be inherited to the child processes of the terminal.

Can anyone spot a security problem in that code?

Cheers,
Christian.



Reply to: