ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/ptytty.C
(Generate patch)

Comparing libptytty/src/ptytty.C (file contents):
Revision 1.10 by root, Sun Jan 22 04:05:19 2006 UTC vs.
Revision 1.15 by root, Mon Jan 23 11:22:08 2006 UTC

6 *----------------------------------------------------------------------* 6 *----------------------------------------------------------------------*
7 * 7 *
8 * All portions of code are copyright by their respective author/s. 8 * All portions of code are copyright by their respective author/s.
9 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com> 9 * Copyright (c) 1999-2001 Geoff Wing <gcw@pobox.com>
10 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com> 10 * Copyright (c) 2004-2006 Marc Lehmann <pcg@goof.com>
11 * Copyright (c) 2006 Emanuele Giaquinta <e.giaquinta@glauco.it>
11 * 12 *
12 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 15 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version. 16 * (at your option) any later version.
370 } 371 }
371 372
372 return true; 373 return true;
373} 374}
374 375
376/////////////////////////////////////////////////////////////////////////////
377// helper/proxy support
378
375#if PTYTTY_HELPER 379#if PTYTTY_HELPER
376 380
377static int sock_fd = -1; 381static int sock_fd = -1;
378static int helper_pid, owner_pid; 382static int helper_pid, owner_pid;
379 383
481 } 485 }
482 } 486 }
483 else if (cmd.type == command::login) 487 else if (cmd.type == command::login)
484 { 488 {
485#if UTMP_SUPPORT 489#if UTMP_SUPPORT
486 if (find (ptys.begin (), ptys.end (), cmd.id)) 490 if (find (ptys.begin (), ptys.end (), cmd.id) != ptys.end ())
487 { 491 {
488 cmd.hostname[sizeof (cmd.hostname) - 1] = 0; 492 cmd.hostname[sizeof (cmd.hostname) - 1] = 0;
489 cmd.id->login (cmd.cmd_pid, cmd.login_shell, cmd.hostname); 493 cmd.id->login (cmd.cmd_pid, cmd.login_shell, cmd.hostname);
490 } 494 }
491#endif 495#endif
608 if (uid != geteuid () 612 if (uid != geteuid ()
609 || gid != getegid ()) 613 || gid != getegid ())
610 ptytty_fatal ("unable to drop privileges, aborting.\n"); 614 ptytty_fatal ("unable to drop privileges, aborting.\n");
611} 615}
612 616
617/////////////////////////////////////////////////////////////////////////////
618// C API
619
620#ifndef NO_C_API
621
622#define DEFINE_METHOD(retval, name, args1, args2) \
623extern "C" retval ptytty_ ## name args1 \
624{ return ((struct ptytty *)ptytty)->name args2; }
625
626DEFINE_METHOD(int,pty,(void *ptytty),)
627DEFINE_METHOD(int,tty,(void *ptytty),)
628DEFINE_METHOD(int,get,(void *ptytty),())
629DEFINE_METHOD(void,login,(void *ptytty, int cmd_pid, bool login_shell, const char *hostname),(cmd_pid,login_shell,hostname))
630
631DEFINE_METHOD(void,close_tty,(void *ptytty),())
632DEFINE_METHOD(int,make_controlling_tty,(void *ptytty),())
633DEFINE_METHOD(void,set_utf8_mode,(void *ptytty, int on),(on))
634
635#define DEFINE_STATIC(retval, name, args) \
636extern "C" retval ptytty_ ## name args \
637{ return ptytty::name args; }
638
639DEFINE_STATIC(void,init,())
640DEFINE_STATIC(void *,create,())
641
642void ptytty_delete (void *ptytty)
643{
644 delete (struct ptytty *)ptytty;
645}
646
647DEFINE_STATIC(void,drop_privileges,())
648DEFINE_STATIC(void,use_helper,())
649
650#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines