00001 // 00002 // plumbing - C++ wrapper facades for Berkeley sockets 00003 // Copyright (C) 2009 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify it 00006 // under the terms of the GNU General Public License, version 3, as published 00007 // by the Free Software Foundation. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT 00010 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00012 // more details. 00013 // 00014 // You should have received a copy of the GNU General Public License along with 00015 // this program. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 00018 #include <cstdio> 00019 #include <pwd.h> 00020 #include <unistd.h> 00021 00022 00023 int 00024 main(int, char **) 00025 { 00026 int u = geteuid(); 00027 struct passwd *pw = getpwuid(u); 00028 if (pw) 00029 printf("%s\n", pw->pw_name); 00030 else 00031 printf("%d\n", u); 00032 return 0; 00033 }