rem
stringlengths 0
83.5k
| add
stringlengths 0
223k
| context
stringlengths 10
471k
| meta
stringlengths 120
236
|
---|---|---|---|
if (i == sockfd) { int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } | if (i == x11Fd) { XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } | int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } | if (i == sockfd) { int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } | int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
int main( int argc, char **argv ) | int main( int , char ** ) | int main( int argc, char **argv ){ char caption[256]; KWidgetIdentification *id = new KWidgetIdentification(); id->getIdentifierByUser( caption ); printf("%s\n", caption);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/681e48fb655ab8a2a8fa7024bd2975b0b77a3d7e/widentify.cpp/buggy/khelpcenter/kwid/widentify.cpp |
int sockfd, i; struct timeval tv; struct sigaction sa; | qInstallMsgHandler(msgHandler); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
||
cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; | printf("kdesud [OPTIONS]...\n"); printf("KDE su daemon (password keeper for KDE su).\n"); printf("\n"); printf("Options:\n"); printf(" -d Give debug information\n"); printf(" -q Be quiet (no warnings)\n"); printf(" -v Show verion information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; | printf("kdesud version %s\n", Version); printf("\n"); printf(" Copyright (c) 1999 Geert Jansen %s\n", Email); printf("\n"); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
cerr << "kdesud: invalid option" << endl; cerr << Help << endl; | printf("kdesud: invalid option\n"); printf("%s\n", Help); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
xerror("setrlimit(): %s"); | qWarning("setrlimit(): %s", strerror(errno)); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
sockfd = create_socket(); | int sockfd = create_socket(); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
xerror("listen(): %s"); | qWarning("listen(): %s", strerror(errno)); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
vector<ConnectionHandler *> handler(FD_SETSIZE); | ConnectionHandler *handler[FD_SETSIZE]; | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
tv.tv_sec = 5; tv.tv_usec = 0; | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
|
xerror("select(): %s"); exit(1); | qFatal("select(): %s", strerror(errno)); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
tv.tv_sec = 5; tv.tv_usec = 0; | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
|
for (i=0; i<FD_SETSIZE; i++) { | for (int i=0; i<FD_SETSIZE; i++) { | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
xerror("accept(): %s"); exit(1); | qWarning("accept(): %s", strerror(errno)); continue; | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
debug("Accepted new connection on fd %d", fd); | qDebug("Accepted new connection on fd %d", fd); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
warning("???"); | qWarning("???"); | int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp |
KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); | KrashConfig krashconf; | int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/72537e6372a97fd535bf849573cf9df3f9bcd6ee/main.cpp/buggy/drkonqi/main.cpp |
KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); | Toplevel w(&krashconf); | int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/72537e6372a97fd535bf849573cf9df3f9bcd6ee/main.cpp/buggy/drkonqi/main.cpp |
KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i; | return w.exec(); | int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/72537e6372a97fd535bf849573cf9df3f9bcd6ee/main.cpp/buggy/drkonqi/main.cpp |
int main( int argc, char **argv ) | int main( int, char ** ) | int main( int argc, char **argv ){ signal(SIGCHLD,sig_handler); signal(SIGSEGV,sig_handler2); // KProtocolManager manager; debug( "kio_ftp : Starting"); Connection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); debug( "kio_ftp : Done" );} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/fd884f5ccde26ca363e9ebd3da6b8cbb9217cd51/main.cc/buggy/kioslave/ftp/main.cc |
KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler")); | KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler"), "unknown"); | int main(int argc, char **argv){ KLocale::setMainCatalogue("kdelibs"); KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler")); KCmdLineArgs::addCmdLineOptions(options); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->count() != 1) return 1; KURL url(args->arg(0)); QStringList cmd; cmd << "--noclose"; cmd << "-e"; if ( url.protocol() == "telnet" ) cmd << "telnet"; else if ( url.protocol() == "rlogin" ) cmd << "rlogin"; else { kdError() << "Invalid protocol " << url.protocol() << endl; return 2; } if (!app.authorize("shell_access")) { KMessageBox::sorry(0, i18n("You do not have permission to access the %1 protocol.").arg(url.protocol())); return 3; } if (!url.user().isEmpty()) { cmd << "-l"; cmd << url.user(); } if (!url.host().isEmpty()) cmd << url.host(); // telnet://host else if (!url.path().isEmpty()) cmd << url.path(); // telnet:host if (url.port()) cmd << QString::number(url.port()); app.kdeinitExec("konsole", cmd); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6025b66bc74be9dc69508a36fe5499dcd37d09b8/ktelnetservice.cpp/clean/kuiserver/ktelnetservice.cpp |
smtp.clear(); smtp.metadata["sasl"] = "LOGIN"; mechs.clear(); mechs.append( "LOGIN" ); AuthCommand auth3( &smtp, mechs, "user", "pass" ); ts.clear(); ts2 = ts; assert( auth3.nextCommandLine( &ts ) == "AUTH LOGIN\r\n" ); assert( !auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "334 VXNlcm5hbWU6" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( auth3.nextCommandLine( &ts ) == "dXNlcg==\r\n" ); assert( !auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "334 go on" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( auth3.nextCommandLine( &ts ) == "cGFzcw==\r\n" ); assert( auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "250 OK" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( !smtp.lastErrorCode ); assert( ts == ts2 ); | int main( int, char** ) { SMTPProtocol smtp; Response r; TransactionState ts, ts2; // // EHLO / HELO // smtp.clear(); EHLOCommand ehlo( &smtp, "mail.example.com" ); // flags assert( ehlo.closeConnectionOnError() ); assert( ehlo.mustBeLastInPipeline() ); assert( !ehlo.mustBeFirstInPipeline() ); // initial state assert( !ehlo.isComplete() ); assert( !ehlo.doNotExecute( 0 ) ); assert( !ehlo.needsResponse() ); // dynamics 1: EHLO succeeds assert( ehlo.nextCommandLine( 0 ) == "EHLO mail.example.com\r\n" ); assert( !ehlo.isComplete() ); // EHLO may fail and we then try HELO assert( ehlo.needsResponse() ); r.clear(); r.parseLine( "250-mail.example.net\r\n" ); r.parseLine( "250-PIPELINING\r\n" ); r.parseLine( "250 8BITMIME\r\n" ); assert( ehlo.processResponse( r, 0 ) == true ); assert( ehlo.isComplete() ); assert( !ehlo.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 2: EHLO fails with "unknown command" smtp.clear(); EHLOCommand ehlo2( &smtp, "mail.example.com" ); ehlo2.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); assert( ehlo2.processResponse( r, 0 ) == true ); assert( !ehlo2.isComplete() ); assert( !ehlo2.needsResponse() ); assert( ehlo2.nextCommandLine( 0 ) == "HELO mail.example.com\r\n" ); assert( ehlo2.isComplete() ); assert( ehlo2.needsResponse() ); r.clear(); r.parseLine( "250 mail.example.net\r\n" ); assert( ehlo2.processResponse( r, 0 ) == true ); assert( !ehlo2.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 3: EHLO fails with unknown response code smtp.clear(); EHLOCommand ehlo3( &smtp, "mail.example.com" ); ehlo3.nextCommandLine( 0 ); r.clear(); r.parseLine( "545 you don't know me\r\n" ); assert( ehlo3.processResponse( r, 0 ) == false ); assert( ehlo3.isComplete() ); assert( !ehlo3.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_UNKNOWN ); // dynamics 4: EHLO _and_ HELO fail with "command unknown" smtp.clear(); EHLOCommand ehlo4( &smtp, "mail.example.com" ); ehlo4.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); ehlo4.processResponse( r, 0 ); ehlo4.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); assert( ehlo4.processResponse( r, 0 ) == false ); assert( ehlo4.isComplete() ); assert( !ehlo4.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_INTERNAL_SERVER ); // // STARTTLS // smtp.clear(); StartTLSCommand tls( &smtp ); // flags assert( tls.closeConnectionOnError() ); assert( tls.mustBeLastInPipeline() ); assert( !tls.mustBeFirstInPipeline() ); // initial state assert( !tls.isComplete() ); assert( !tls.doNotExecute( 0 ) ); assert( !tls.needsResponse() ); // dynamics 1: ok from server, TLS negotiation successful ts.clear(); ts2 = ts; assert( tls.nextCommandLine( &ts ) == "STARTTLS\r\n" ); assert( ts == ts2 ); assert( tls.isComplete() ); assert( tls.needsResponse() ); r.clear(); r.parseLine( "220 Go ahead" ); smtp.startTLSReturnCode = 1; assert( tls.processResponse( r, &ts ) == true ); assert( !tls.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // dynamics 2: NAK from server smtp.clear(); StartTLSCommand tls2( &smtp ); ts.clear(); tls2.nextCommandLine( &ts ); r.clear(); r.parseLine( "454 TLS temporarily disabled" ); smtp.startTLSReturnCode = 1; assert( tls2.processResponse( r, &ts ) == false ); assert( !tls2.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_SERVICE_NOT_AVAILABLE ); // dynamics 3: ok from server, TLS negotiation unsuccessful smtp.clear(); StartTLSCommand tls3( &smtp ); ts.clear(); tls3.nextCommandLine( &ts ); r.clear(); r.parseLine( "220 Go ahead" ); smtp.startTLSReturnCode = -1; assert( tls.processResponse( r, &ts ) == false ); assert( !tls.needsResponse() ); // // AUTH // smtp.clear(); QStrIList mechs; mechs.append( "PLAIN" ); smtp.metadata["sasl"] = "PLAIN"; AuthCommand auth( &smtp, mechs, "user", "pass" ); // flags assert( auth.closeConnectionOnError() ); assert( auth.mustBeLastInPipeline() ); assert( !auth.mustBeFirstInPipeline() ); // initial state assert( !auth.isComplete() ); assert( !auth.doNotExecute( 0 ) ); assert( !auth.needsResponse() ); // dynamics 1: TLS, so AUTH should include initial-response: smtp.usesTLS = true; ts.clear(); ts2 = ts; assert( auth.nextCommandLine( &ts ) == "AUTH PLAIN dXNlcgB1c2VyAHBhc3M=\r\n" ); assert( auth.isComplete() ); assert( auth.needsResponse() ); assert( ts == ts2 ); r.clear(); r.parseLine( "250 OK" ); // dynamics 2: No TLS, so AUTH should not include initial-response: smtp.clear(); smtp.metadata["sasl"] = "PLAIN"; smtp.usesTLS = false; AuthCommand auth2( &smtp, mechs, "user", "pass" ); ts.clear(); assert( auth2.nextCommandLine( &ts ) == "AUTH PLAIN\r\n" ); assert( !auth2.isComplete() ); assert( auth2.needsResponse() ); r.clear(); r.parseLine( "334 Go on" ); assert( auth2.processResponse( r, &ts ) == true ); assert( auth2.nextCommandLine( &ts ) == "dXNlcgB1c2VyAHBhc3M=\r\n" ); assert( auth2.isComplete() ); assert( auth2.needsResponse() ); // // MAIL FROM: // smtp.clear(); MailFromCommand mail( &smtp, "[email protected]" ); // flags assert( !mail.closeConnectionOnError() ); assert( !mail.mustBeLastInPipeline() ); assert( !mail.mustBeFirstInPipeline() ); // initial state assert( !mail.isComplete() ); assert( !mail.doNotExecute( 0 ) ); assert( !mail.needsResponse() ); // dynamics: success, no size, no 8bit ts.clear(); ts2 = ts; assert( mail.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]>\r\n" ); assert( ts2 == ts ); assert( mail.isComplete() ); assert( mail.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( mail.processResponse( r, &ts ) == true ); assert( !mail.needsResponse() ); assert( ts == ts2 ); assert( smtp.lastErrorCode == 0 ); // dynamics: success, size, 8bit, but no SIZE, 8BITMIME caps smtp.clear(); MailFromCommand mail2( &smtp, "[email protected]", true, 500 ); ts.clear(); ts2 = ts; assert( mail2.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]>\r\n" ); assert( ts == ts2 ); // dynamics: success, size, 8bit, SIZE, 8BITMIME caps smtp.clear(); MailFromCommand mail3( &smtp, "[email protected]", true, 500 ); ts.clear(); ts2 = ts; smtp.caps << "SIZE" << "8BITMIME" ; assert( mail3.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]> BODY=8BITMIME SIZE=500\r\n" ); assert( ts == ts2 ); // dynamics: failure smtp.clear(); MailFromCommand mail4( &smtp, "[email protected]" ); ts.clear(); mail4.nextCommandLine( &ts ); r.clear(); r.parseLine( "503 Bad sequence of commands" ); assert( mail4.processResponse( r, &ts ) == false ); assert( mail4.isComplete() ); assert( !mail4.needsResponse() ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // // RCPT TO: // smtp.clear(); RcptToCommand rcpt( &smtp, "[email protected]" ); // flags assert( !rcpt.closeConnectionOnError() ); assert( !rcpt.mustBeLastInPipeline() ); assert( !rcpt.mustBeFirstInPipeline() ); // initial state assert( !rcpt.isComplete() ); assert( !rcpt.doNotExecute( 0 ) ); assert( !rcpt.needsResponse() ); // dynamics: success ts.clear(); ts2 = ts; assert( rcpt.nextCommandLine( &ts ) == "RCPT TO:<[email protected]>\r\n" ); assert( ts == ts2 ); assert( rcpt.isComplete() ); assert( rcpt.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( rcpt.processResponse( r, &ts ) == true ); assert( !rcpt.needsResponse() ); assert( ts.atLeastOneRecipientWasAccepted() ); assert( !ts.haveRejectedRecipients() ); assert( !ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // dynamics: failure smtp.clear(); RcptToCommand rcpt2( &smtp, "[email protected]" ); ts.clear(); rcpt2.nextCommandLine( &ts ); r.clear(); r.parseLine( "530 5.7.1 Relaying not allowed!" ); assert( rcpt2.processResponse( r, &ts ) == false ); assert( rcpt2.isComplete() ); assert( !rcpt2.needsResponse() ); assert( !ts.atLeastOneRecipientWasAccepted() ); assert( ts.haveRejectedRecipients() ); assert( ts.rejectedRecipients().count() == 1 ); assert( ts.rejectedRecipients().front().recipient == "[email protected]" ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // dynamics: success and failure combined smtp.clear(); RcptToCommand rcpt3( &smtp, "[email protected]" ); RcptToCommand rcpt4( &smtp, "[email protected]" ); RcptToCommand rcpt5( &smtp, "[email protected]" ); ts.clear(); rcpt3.nextCommandLine( &ts ); r.clear(); r.parseLine( "530 5.7.1 Relaying not allowed!" ); rcpt3.processResponse( r, &ts ); rcpt4.nextCommandLine( &ts ); r.clear(); r.parseLine( "250 Ok" ); rcpt4.processResponse( r, &ts ); rcpt5.nextCommandLine( &ts ); r.clear(); r.parseLine( "250 Ok" ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( ts.haveRejectedRecipients() ); assert( ts.atLeastOneRecipientWasAccepted() ); assert( smtp.lastErrorCode == 0 ); // // DATA (init) // smtp.clear(); DataCommand data( &smtp ); // flags assert( !data.closeConnectionOnError() ); assert( data.mustBeLastInPipeline() ); assert( !data.mustBeFirstInPipeline() ); // initial state assert( !data.isComplete() ); assert( !data.doNotExecute( 0 ) ); assert( !data.needsResponse() ); // dynamics: success ts.clear(); assert( data.nextCommandLine( &ts ) == "DATA\r\n" ); assert( data.isComplete() ); assert( data.needsResponse() ); assert( ts.dataCommandIssued() ); assert( !ts.dataCommandSucceeded() ); r.clear(); r.parseLine( "354 Send data, end in <CR><LF>.<CR><LF>" ); assert( data.processResponse( r, &ts ) == true ); assert( !data.needsResponse() ); assert( ts.dataCommandSucceeded() ); assert( ts.dataResponse() == r ); assert( smtp.lastErrorCode == 0 ); // dynamics: failure smtp.clear(); DataCommand data2( &smtp ); ts.clear(); data2.nextCommandLine( &ts ); r.clear(); r.parseLine( "551 No valid recipients" ); assert( data2.processResponse( r, &ts ) == false ); assert( !data2.needsResponse() ); assert( !ts.dataCommandSucceeded() ); assert( ts.dataResponse() == r ); assert( smtp.lastErrorCode == 0 ); // // DATA (transfer) // TransferCommand xfer( &smtp, 0 ); // flags assert( !xfer.closeConnectionOnError() ); assert( !xfer.mustBeLastInPipeline() ); assert( xfer.mustBeFirstInPipeline() ); // initial state assert( !xfer.isComplete() ); assert( !xfer.needsResponse() ); // dynamics 1: DATA command failed ts.clear(); r.clear(); r.parseLine( "551 no valid recipients" ); ts.setDataCommandIssued( true ); ts.setDataCommandSucceeded( false, r ); assert( xfer.doNotExecute( &ts ) ); // dynamics 2: some recipients rejected, but not all smtp.clear(); TransferCommand xfer2( &smtp, 0 ); ts.clear(); ts.setRecipientAccepted(); ts.addRejectedRecipient( "[email protected]", "No relaying allowed" ); ts.setDataCommandIssued( true ); r.clear(); r.parseLine( "354 go on" ); ts.setDataCommandSucceeded( true, r ); // ### will change with allow-partial-delivery option: assert( xfer.doNotExecute( &ts ) ); // successful dynamics with all combinations of: enum { EndInLF = 1, PerformDotStuff = 2, UngetLast = 4, Preloading = 8, Error = 16, EndOfOptions = 32 }; for ( unsigned int i = 0 ; i < EndOfOptions ; ++i ) checkSuccessfulTransferCommand( i & Error, i & Preloading, i & UngetLast, i & PerformDotStuff, i & EndInLF ); // // NOOP // smtp.clear(); NoopCommand noop( &smtp ); // flags assert( !noop.closeConnectionOnError() ); assert( noop.mustBeLastInPipeline() ); assert( !noop.mustBeFirstInPipeline() ); // initial state assert( !noop.isComplete() ); assert( !noop.doNotExecute( &ts ) ); assert( !noop.needsResponse() ); // dynamics: success (failure is tested with RSET) assert( noop.nextCommandLine( 0 ) == "NOOP\r\n" ); assert( noop.isComplete() ); assert( noop.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( noop.processResponse( r, 0 ) == true ); assert( noop.isComplete() ); assert( !noop.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // // RSET // smtp.clear(); RsetCommand rset( &smtp ); // flags assert( rset.closeConnectionOnError() ); assert( !rset.mustBeLastInPipeline() ); assert( !rset.mustBeFirstInPipeline() ); // initial state assert( !rset.isComplete() ); assert( !rset.doNotExecute( &ts ) ); assert( !rset.needsResponse() ); // dynamics: failure (success is tested with NOOP/QUIT) assert( rset.nextCommandLine( 0 ) == "RSET\r\n" ); assert( rset.isComplete() ); assert( rset.needsResponse() ); r.clear(); r.parseLine( "502 command not implemented" ); assert( rset.processResponse( r, 0 ) == false ); assert( rset.isComplete() ); assert( !rset.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // an RSET failure isn't worth it, is it? assert( smtp.lastErrorMessage.isNull() ); // // QUIT // smtp.clear(); QuitCommand quit( &smtp ); // flags assert( quit.closeConnectionOnError() ); assert( quit.mustBeLastInPipeline() ); assert( !quit.mustBeFirstInPipeline() ); // initial state assert( !quit.isComplete() ); assert( !quit.doNotExecute( 0 ) ); assert( !quit.needsResponse() ); // dynamics 1: success assert( quit.nextCommandLine( 0 ) == "QUIT\r\n" ); assert( quit.isComplete() ); assert( quit.needsResponse() ); r.clear(); r.parseLine( "221 Goodbye" ); assert( quit.processResponse( r, 0 ) == true ); assert( quit.isComplete() ); assert( !quit.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 2: success smtp.clear(); QuitCommand quit2( &smtp ); quit2.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command" ); assert( quit2.processResponse( r, 0 ) == false ); assert( quit2.isComplete() ); assert( !quit2.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // an QUIT failure isn't worth it, is it? assert( smtp.lastErrorMessage.isNull() ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/31a620dc8fd05e2c6443143fb88c876d063ba0d1/test_commands.cc/clean/kioslave/smtp/test_commands.cc |
|
if ( args->isSet("maximize-vertical") ) { state |= NET::MaxVert; mask |= NET::MaxVert; } if ( args->isSet("maximize-horizontal") ) { state |= NET::MaxHoriz; mask |= NET::MaxHoriz; } | int main( int argc, char *argv[] ){ // David, 05/03/2000 KAboutData aboutData( "kstart", I18N_NOOP("KStart"), KSTART_VERSION, I18N_NOOP("" "Utility to launch applications with special window properties \n" "such as iconified, maximized, a certain virtual desktop, a special decoration\n" "and so on." ), KAboutData::License_GPL, "(C) 1997-2000 Matthias Ettrich ([email protected])" ); aboutData.addAuthor( "Matthias Ettrich", 0, "[email protected]" ); aboutData.addAuthor( "David Faure", 0, "[email protected]" ); aboutData.addAuthor( "Richard J. Moore", 0, "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if ( args->count() == 0 ) KCmdLineArgs::usage(i18n("No command specified")); // Perhaps we should use a konsole-like solution here (shell, list of args...) for(int i=0; i < args->count(); i++) command += QCString(args->arg(i)) + " "; kwinmodule = new KWinModule; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; if ( args->isSet ( "currentdesktop") ) desktop = kwinmodule->currentDesktop(); window = args->getOption( "window" ); if( window.isEmpty()) kdWarning() << "Omitting --window argument is not recommended" << endl; QCString s = args->getOption( "type" ); if ( !s.isEmpty() ) { s = s.lower(); if ( s == "desktop" ) windowtype = NET::Desktop; else if ( s == "dock" ) windowtype = NET::Dock; else if ( s == "tool" ) windowtype = NET::Tool; else if ( s == "menu" ) windowtype = NET::Menu; else if ( s == "dialog" ) windowtype = NET::Dialog; else if ( s == "override" ) windowtype = NET::Override; else if ( s == "topmenu" ) windowtype = NET::TopMenu; else windowtype = NET::Normal; } if ( args->isSet( "keepabove" ) ) { state |= NET::KeepAbove; mask |= NET::KeepAbove; } else if ( args->isSet( "keepbelow" ) ) { state |= NET::KeepBelow; mask |= NET::KeepBelow; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } if ( args->isSet( "skippager" ) ) { state |= NET::SkipPager; mask |= NET::SkipPager; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); toSysTray = args->isSet("tosystray"); if ( args->isSet("fullscreen") ) { NETRootInfo i( qt_xdisplay(), NET::Supported ); if( i.isSupported( NET::FullScreen )) { state |= NET::FullScreen; mask |= NET::FullScreen; } else { windowtype = NET::Override; fullscreen = true; } } fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; QTimer::singleShot( 120 * 1000, &app, SLOT( quit())); // quit if nothing happens in 2 minutes return app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/c2b4600d9ec8de475b9132f3ef36375d5311574f/kstart.cpp/buggy/kstart/kstart.cpp |
|
CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); | client[i] = new Client(mdc, i, new TCPMessenger(MSG_ADDR_CLIENT(i))); | int main(int oargc, char **oargv) { //cerr << "tcpfuse starting " << myrank << "/" << world << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); int start = 0; // build new argc+argv for fuse typedef char* pchar; int nargc = 0; char **nargv = new pchar[argc]; nargv[nargc++] = argv[0]; int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } int myrank = tcpmessenger_init(argc, argv); int world = tcpmessenger_world(); assert(NUMMDS + NUMOSD + NUMCLIENT <= world); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new TCPMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new TCPMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); start++; } // start message loop if (start) { tcpmessenger_start(); // init for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; client[i]->init(); // start up fuse // use my argc, argv (make sure you pass a mount point!) cout << "mounting" << endl; client[i]->mount(mkfs); cout << "starting fuse on rank " << myrank << " pid " << getpid() << endl; ceph_fuse_main(client[i], nargc, nargv); cout << "fuse finished on rank " << myrank << " pid " << getpid() << endl; } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; client[i]->unmount(); cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish tcpmessenger_wait(); } else { cerr << "IDLE rank " << myrank << endl; } tcpmessenger_shutdown(); // shutdown MPI // cleanup for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; delete mds[i]; } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; delete client[i]; } delete mdc; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/d3ef7c44debfa7997367cff009dac1b770aa56a4/tcpfuse.cc/clean/ceph/tcpfuse.cc |
I18N_NOOP("Informs KDE about a change in hostname."), | I18N_NOOP("Informs KDE about a change in hostname"), | int main(int argc, char **argv){ KLocale::setMainCatalogue("kdelibs"); KAboutData d(appName, I18N_NOOP("KDontChangeTheHostName"), appVersion, I18N_NOOP("Informs KDE about a change in hostname."), KAboutData::License_GPL, "(c) 2001 Waldo Bastian"); d.addAuthor("Waldo Bastian", I18N_NOOP("Author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &d); KCmdLineArgs::addCmdLineOptions(options); KInstance k(&d); KHostName hn; hn.changeX(); hn.changeDcop(); hn.changeStdDirs("socket"); hn.changeStdDirs("tmp"); hn.changeSessionManager();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/3fafa89f53ff6e68db369d41a28646cd680c5c40/khostname.cpp/clean/kdontchangethehostname/khostname.cpp |
konfig = new KConfig(file, true, args->isSet("usekdeglobals")); | konfig = new KConfig(file, true, false); | int main(int argc, char **argv){ KAboutData aboutData("kreadconfig", I18N_NOOP("KReadConfig"), "1.0.1", I18N_NOOP("Read KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc."); aboutData.addAuthor("Bernhard Rosenkraenzer", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString dflt=args->getOption("default"); QCString type=args->getOption("type").lower(); if (key.isNull()) { KCmdLineArgs::usage(); return 1; } KInstance inst(&aboutData); KConfig *konfig; bool configMustDeleted = false; if (file.isEmpty()) konfig = KGlobal::config(); else { konfig = new KConfig(file, true, args->isSet("usekdeglobals")); configMustDeleted=true; } konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); bool retValue = !konfig->readBoolEntry(key, def); if ( configMustDeleted ) delete konfig; return retValue; } else if((type=="num") || (type=="int")) { long retValue = konfig->readLongNumEntry(key, dflt.toLong()); if ( configMustDeleted ) delete konfig; return retValue; } else if (type=="path"){ fprintf(stdout, "%s\n", konfig->readPathEntry(key, dflt).local8Bit().data()); if ( configMustDeleted ) delete konfig; return 0; } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); if ( configMustDeleted ) delete konfig; return 0; }} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/af02eea83ce0ca99b8e8f7be141ed230c640e1c3/kreadconfig.cpp/clean/kreadconfig/kreadconfig.cpp |
cerr << "fakesyn starting" << endl; | int main(int oargc, char **oargv) { cerr << "fakesyn starting" << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); int start = 0; // build new argc+argv for fuse typedef char* pchar; int nargc = 0; char **nargv = new pchar[argc]; nargv[nargc++] = argv[0]; string syn_sarg1; int syn_mode = SYNCLIENT_MODE_WRITEFILE; int syn_iarg1, syn_iarg2, syn_iarg3; int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else if (strcmp(argv[i],"--synsarg1") == 0) syn_sarg1 = argv[++i]; else if (strcmp(argv[i],"--syniarg1") == 0) syn_iarg1 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg2") == 0) syn_iarg2 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg3") == 0) syn_iarg3 = atoi(argv[++i]); else if (strcmp(argv[i],"--synmode") == 0) { ++i; if (strcmp(argv[i],"writefile") == 0) syn_mode = SYNCLIENT_MODE_WRITEFILE; else if (strcmp(argv[i],"makedirs") == 0) syn_mode = SYNCLIENT_MODE_MAKEDIRS; else if (strcmp(argv[i],"fullwalk") == 0) syn_mode = SYNCLIENT_MODE_FULLWALK; else if (strcmp(argv[i],"randomwalk") == 0) syn_mode = SYNCLIENT_MODE_RANDOMWALK; else { cerr << "unknown syn mode " << argv[i] << endl; return -1; } } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { //cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { //cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; SyntheticClient *syn[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { //cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; CheesySerializer *serializer = new CheesySerializer( new FakeMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); start++; } // start message loop fakemessenger_startthread(); // init for (int i=0; i<NUMMDS; i++) { mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { client[i]->init(); // use my argc, argv (make sure you pass a mount point!) //cout << "mounting" << endl; client[i]->mount(mkfs); //cout << "starting synthetic client " << endl; syn[i] = new SyntheticClient(client[i]); char s[20]; sprintf(s,"syn.%d", i); syn[i]->sarg1 = s; syn[i]->mode = syn_mode; syn[i]->iarg1 = syn_iarg1; syn[i]->iarg2 = syn_iarg2; syn[i]->iarg3 = syn_iarg3; syn[i]->start_thread(); } for (int i=0; i<NUMCLIENT; i++) { cout << "waiting for synthetic client " << i << " to finish" << endl; syn[i]->join_thread(); delete syn[i]; client[i]->unmount(); //cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish fakemessenger_wait(); // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; free(argv); delete[] nargv; cout << "fakesyn done" << endl; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/d3ef7c44debfa7997367cff009dac1b770aa56a4/fakesyn.cc/clean/ceph/fakesyn.cc |
|
CheesySerializer *serializer = new CheesySerializer( new FakeMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); | client[i] = new Client(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(i))); | int main(int oargc, char **oargv) { cerr << "fakesyn starting" << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); int start = 0; // build new argc+argv for fuse typedef char* pchar; int nargc = 0; char **nargv = new pchar[argc]; nargv[nargc++] = argv[0]; string syn_sarg1; int syn_mode = SYNCLIENT_MODE_WRITEFILE; int syn_iarg1, syn_iarg2, syn_iarg3; int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else if (strcmp(argv[i],"--synsarg1") == 0) syn_sarg1 = argv[++i]; else if (strcmp(argv[i],"--syniarg1") == 0) syn_iarg1 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg2") == 0) syn_iarg2 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg3") == 0) syn_iarg3 = atoi(argv[++i]); else if (strcmp(argv[i],"--synmode") == 0) { ++i; if (strcmp(argv[i],"writefile") == 0) syn_mode = SYNCLIENT_MODE_WRITEFILE; else if (strcmp(argv[i],"makedirs") == 0) syn_mode = SYNCLIENT_MODE_MAKEDIRS; else if (strcmp(argv[i],"fullwalk") == 0) syn_mode = SYNCLIENT_MODE_FULLWALK; else if (strcmp(argv[i],"randomwalk") == 0) syn_mode = SYNCLIENT_MODE_RANDOMWALK; else { cerr << "unknown syn mode " << argv[i] << endl; return -1; } } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { //cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { //cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; SyntheticClient *syn[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { //cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; CheesySerializer *serializer = new CheesySerializer( new FakeMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); start++; } // start message loop fakemessenger_startthread(); // init for (int i=0; i<NUMMDS; i++) { mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { client[i]->init(); // use my argc, argv (make sure you pass a mount point!) //cout << "mounting" << endl; client[i]->mount(mkfs); //cout << "starting synthetic client " << endl; syn[i] = new SyntheticClient(client[i]); char s[20]; sprintf(s,"syn.%d", i); syn[i]->sarg1 = s; syn[i]->mode = syn_mode; syn[i]->iarg1 = syn_iarg1; syn[i]->iarg2 = syn_iarg2; syn[i]->iarg3 = syn_iarg3; syn[i]->start_thread(); } for (int i=0; i<NUMCLIENT; i++) { cout << "waiting for synthetic client " << i << " to finish" << endl; syn[i]->join_thread(); delete syn[i]; client[i]->unmount(); //cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish fakemessenger_wait(); // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; free(argv); delete[] nargv; cout << "fakesyn done" << endl; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/d3ef7c44debfa7997367cff009dac1b770aa56a4/fakesyn.cc/clean/ceph/fakesyn.cc |
if (id != app.dcopClient()->registerAs(id)) | if (id != app.dcopClient()->registerAs(id, false)) | int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcmroot"); app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); // see if we really run as root if (getuid() != 0) { cerr << "Only root will run this program!" << endl; exit(-1); } // check parameters if ((argc < 2) || (argc > 3)) { cerr << i18n("usage: kcmroot module.desktop [dcopserver]") << endl; exit(-1); } // load the module ModuleInfo info(argv[1]); KCModule *module = ModuleLoader::module(info, 0); if (module) { RemoteProxy proxy(module, info.moduleId()); if (!app.dcopClient()->attach()) return -1; QCString id = info.moduleId(); if (id != app.dcopClient()->registerAs(id)) cerr << "Warning: multiple instances registered" << endl; // show the proxy module->move(10000, 10000); return app.exec(); } return -1;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/f5e6d435f9c231d010cddc913f20ab294519b7ec/kcmroot.cpp/buggy/kcontrol/kcontrol/kcmroot.cpp |
if(qApp->applicationFilePath().contains("/src/qgis")) | #if defined(Q_OS_MACX) || defined(WIN32) QString appPath = qApp->applicationFilePath(); QString appDir = qApp->applicationDirPath(); QString testFile = "Makefile"; #else QString appPath = argv[0]; QString appDir = appPath.left(appPath.findRev("/")); QString testFile = "lt-qgis"; #endif if(appPath.contains("/src/")) | int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 if ( !bundleclicked(argc, argv) ) { //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName = optarg; break; case 'l': myTranslationFileName = optarg; break; case 'p': myProjectFileName = optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode not supported.\n You are seeing this message most likely because you have no DISPLAY environment variable set." << std::endl; exit(1); //exit for now until a version of qgis is capabable of running non interactive } QApplication a(argc, argv, myUseGuiFlag ); // Check to see if qgis was started from the source directory. // This is done by looking for Makefile in the directory where qgis was // started from. If running from the src directory, exit gracefully if(qApp->applicationFilePath().contains("/src/qgis")) { // check to see if configure is present in the directory QFileInfo fi(qApp->applicationDirPath() + "/Makefile"); if(fi.exists()) { QMessageBox::critical(0,"QGIS Not Installed", "You appear to be running QGIS from the source directory.\n" "You must install QGIS using make install and run it from the " "installed directory."); exit(1); } } // a.setFont(QFont("helvetica", 11));#if defined(Q_OS_MACX) || defined(WIN32) QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif QTranslator tor(0); // For WIN32, get the locale if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else {#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #endif tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // If no --project was specified, parse the args to look for a // // .qgs file and set myProjectFileName to it. This allows loading // // of a project file by clicking on it in various desktop managers // // where an appropriate mime-type has been set up. // ///////////////////////////////////////////////////////////////////// if(myProjectFileName.isEmpty()) { // check for a .qgs for(int i = 0; i < argc; i++) { QString arg = argv[i]; if(arg.contains(".qgs")) { myProjectFileName = argv[i]; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) {// if ( ! qgis->addProject(myProjectFileName) )// {// #ifdef QGISDEBUG// std::cerr << "unable to load project " << myProjectFileName << "\n";// #endif// } try { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } catch ( QgsIOException & io_exception ) { QMessageBox::critical( 0x0, "QGIS: Unable to load project", "Unable to load project " + myProjectFileName ); } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(QFileInfo(myLayerName), false); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(QFileInfo(myLayerName)); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/204c1d1f322fe615a8c4ab029165b2f86c66972d/main.cpp/clean/src/main.cpp |
QFileInfo fi(qApp->applicationDirPath() + "/Makefile"); | QFileInfo fi(appDir + "/" + testFile); | int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 if ( !bundleclicked(argc, argv) ) { //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName = optarg; break; case 'l': myTranslationFileName = optarg; break; case 'p': myProjectFileName = optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode not supported.\n You are seeing this message most likely because you have no DISPLAY environment variable set." << std::endl; exit(1); //exit for now until a version of qgis is capabable of running non interactive } QApplication a(argc, argv, myUseGuiFlag ); // Check to see if qgis was started from the source directory. // This is done by looking for Makefile in the directory where qgis was // started from. If running from the src directory, exit gracefully if(qApp->applicationFilePath().contains("/src/qgis")) { // check to see if configure is present in the directory QFileInfo fi(qApp->applicationDirPath() + "/Makefile"); if(fi.exists()) { QMessageBox::critical(0,"QGIS Not Installed", "You appear to be running QGIS from the source directory.\n" "You must install QGIS using make install and run it from the " "installed directory."); exit(1); } } // a.setFont(QFont("helvetica", 11));#if defined(Q_OS_MACX) || defined(WIN32) QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif QTranslator tor(0); // For WIN32, get the locale if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else {#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #endif tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // If no --project was specified, parse the args to look for a // // .qgs file and set myProjectFileName to it. This allows loading // // of a project file by clicking on it in various desktop managers // // where an appropriate mime-type has been set up. // ///////////////////////////////////////////////////////////////////// if(myProjectFileName.isEmpty()) { // check for a .qgs for(int i = 0; i < argc; i++) { QString arg = argv[i]; if(arg.contains(".qgs")) { myProjectFileName = argv[i]; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) {// if ( ! qgis->addProject(myProjectFileName) )// {// #ifdef QGISDEBUG// std::cerr << "unable to load project " << myProjectFileName << "\n";// #endif// } try { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } catch ( QgsIOException & io_exception ) { QMessageBox::critical( 0x0, "QGIS: Unable to load project", "Unable to load project " + myProjectFileName ); } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(QFileInfo(myLayerName), false); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(QFileInfo(myLayerName)); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/204c1d1f322fe615a8c4ab029165b2f86c66972d/main.cpp/clean/src/main.cpp |
qDebug( "kio_ftp : Starting"); | KInstance instance( "kio_ftp" ); | int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler); signal(SIGSEGV, KIOProtocol::sigsegv_handler); // KProtocolManager manager; qDebug( "kio_ftp : Starting"); KInstance instance( "kio_ftp" ); KIOConnection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); qDebug( "kio_ftp : Done" );} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/62a34169840bd1768b62f75500dfb95480b14c0f/main.cc/buggy/kioslave/ftp/main.cc |
KInstance instance( "kio_ftp" ); | kdebug( KDEBUG_INFO, 0, "Starting"); | int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler); signal(SIGSEGV, KIOProtocol::sigsegv_handler); // KProtocolManager manager; qDebug( "kio_ftp : Starting"); KInstance instance( "kio_ftp" ); KIOConnection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); qDebug( "kio_ftp : Done" );} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/62a34169840bd1768b62f75500dfb95480b14c0f/main.cc/buggy/kioslave/ftp/main.cc |
qDebug( "kio_ftp : Done" ); | kdebug( KDEBUG_INFO, 0, "Done"); | int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler); signal(SIGSEGV, KIOProtocol::sigsegv_handler); // KProtocolManager manager; qDebug( "kio_ftp : Starting"); KInstance instance( "kio_ftp" ); KIOConnection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); qDebug( "kio_ftp : Done" );} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/62a34169840bd1768b62f75500dfb95480b14c0f/main.cc/buggy/kioslave/ftp/main.cc |
fakemessenger_stopthread(); | fakemessenger_wait(); | int main(int oargc, char **oargv) { cerr << "fakefuse starting" << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // start messenger thread fakemessenger_startthread(); //g_timer.add_event_after(5.0, new C_Test2); //g_timer.add_event_after(10.0, new C_Test); int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; argv[i] = 0; argc--; break; } if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; argv[i] = 0; argc--; break; } } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); osd[i]->init(); } // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); mds[i]->init(); } // create client Client *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { client[i] = new Client(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(0))); client[i]->init(); // start up fuse // use my argc, argv (make sure you pass a mount point!) cout << "starting fuse on pid " << getpid() << endl; client[i]->mount(mkfs); ceph_fuse_main(client[i], argc, argv); client[i]->unmount(); cout << "fuse finished on pid " << getpid() << endl; client[i]->shutdown(); } // wait for it to finish cout << "DONE -----" << endl; fakemessenger_stopthread(); // blocks until messenger stops // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/8c7283a709cbd1031e4adc5c129a44d81b7a0f8d/fakefuse.cc/clean/ceph/fakefuse.cc |
kdebug(KDEBUG_FATAL,1401,"It seems that the khelpcenter server isn't running!"); | kdFatal(1401) << "It seems that the khelpcenter server isn't running!" << endl; | int main(int argc, char *argv[]){ bool enableTree = false; int command = 0; QString url; // no parameters -> print usage if(argc == 1) { usage(); return 0; } // parse command line parameters for (int i = 1; i < argc; i++) { if (strcasecmp(argv[i], "configure") == 0) { command = 1; break; } else if (strcasecmp(argv[i], "-enable_tree") == 0) { enableTree = true; } else if (command == 2) // already found 'open'...this must be a url { url = argv[i]; } else if (strcasecmp( argv[i], "open" ) == 0) { command = 2; } } if (command == 0) { usage(); return 0; } KOMApplication app(argc, argv, "khelpcenterclient"); // init CORBA stuff CORBA::Object_var obj = app.orb()->bind("IDL:KHelpCenter/HelpCenterCom:1.0", "inet:localhost:8887"); if(CORBA::is_nil(obj)) { kdebug(KDEBUG_FATAL,1401,"It seems that the khelpcenter server isn't running!"); return 0; } KHelpCenter::HelpCenterCom_var server = KHelpCenter::HelpCenterCom::_narrow(obj); kdebug(KDEBUG_INFO,1401,"binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0"); if (command == 1) { kdebug(KDEBUG_INFO,1401,"khelpcenterclient -configure"); server->configure(); } else if (command == 2) { if (url.isEmpty()) url = "file:" + locate("html", "default/khelpcenter/main.html"); kdebug(KDEBUG_INFO,1401,"khelpcenterclient open %s", url.ascii()); server->openHelpView (url, enableTree); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6e70c325b7e97c99756efc38fc56ff93bf507450/khelpcenterclient.cpp/clean/khelpcenter/helpcenter/khelpcenterclient.cpp |
kdebug(KDEBUG_INFO,1401,"binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0"); | kdDebug(1401) << "binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0" << endl; | int main(int argc, char *argv[]){ bool enableTree = false; int command = 0; QString url; // no parameters -> print usage if(argc == 1) { usage(); return 0; } // parse command line parameters for (int i = 1; i < argc; i++) { if (strcasecmp(argv[i], "configure") == 0) { command = 1; break; } else if (strcasecmp(argv[i], "-enable_tree") == 0) { enableTree = true; } else if (command == 2) // already found 'open'...this must be a url { url = argv[i]; } else if (strcasecmp( argv[i], "open" ) == 0) { command = 2; } } if (command == 0) { usage(); return 0; } KOMApplication app(argc, argv, "khelpcenterclient"); // init CORBA stuff CORBA::Object_var obj = app.orb()->bind("IDL:KHelpCenter/HelpCenterCom:1.0", "inet:localhost:8887"); if(CORBA::is_nil(obj)) { kdebug(KDEBUG_FATAL,1401,"It seems that the khelpcenter server isn't running!"); return 0; } KHelpCenter::HelpCenterCom_var server = KHelpCenter::HelpCenterCom::_narrow(obj); kdebug(KDEBUG_INFO,1401,"binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0"); if (command == 1) { kdebug(KDEBUG_INFO,1401,"khelpcenterclient -configure"); server->configure(); } else if (command == 2) { if (url.isEmpty()) url = "file:" + locate("html", "default/khelpcenter/main.html"); kdebug(KDEBUG_INFO,1401,"khelpcenterclient open %s", url.ascii()); server->openHelpView (url, enableTree); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6e70c325b7e97c99756efc38fc56ff93bf507450/khelpcenterclient.cpp/clean/khelpcenter/helpcenter/khelpcenterclient.cpp |
kdebug(KDEBUG_INFO,1401,"khelpcenterclient -configure"); | kdDebug(1401) << "khelpcenterclient -configure" << endl; | int main(int argc, char *argv[]){ bool enableTree = false; int command = 0; QString url; // no parameters -> print usage if(argc == 1) { usage(); return 0; } // parse command line parameters for (int i = 1; i < argc; i++) { if (strcasecmp(argv[i], "configure") == 0) { command = 1; break; } else if (strcasecmp(argv[i], "-enable_tree") == 0) { enableTree = true; } else if (command == 2) // already found 'open'...this must be a url { url = argv[i]; } else if (strcasecmp( argv[i], "open" ) == 0) { command = 2; } } if (command == 0) { usage(); return 0; } KOMApplication app(argc, argv, "khelpcenterclient"); // init CORBA stuff CORBA::Object_var obj = app.orb()->bind("IDL:KHelpCenter/HelpCenterCom:1.0", "inet:localhost:8887"); if(CORBA::is_nil(obj)) { kdebug(KDEBUG_FATAL,1401,"It seems that the khelpcenter server isn't running!"); return 0; } KHelpCenter::HelpCenterCom_var server = KHelpCenter::HelpCenterCom::_narrow(obj); kdebug(KDEBUG_INFO,1401,"binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0"); if (command == 1) { kdebug(KDEBUG_INFO,1401,"khelpcenterclient -configure"); server->configure(); } else if (command == 2) { if (url.isEmpty()) url = "file:" + locate("html", "default/khelpcenter/main.html"); kdebug(KDEBUG_INFO,1401,"khelpcenterclient open %s", url.ascii()); server->openHelpView (url, enableTree); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6e70c325b7e97c99756efc38fc56ff93bf507450/khelpcenterclient.cpp/clean/khelpcenter/helpcenter/khelpcenterclient.cpp |
kdebug(KDEBUG_INFO,1401,"khelpcenterclient open %s", url.ascii()); | kdDebug(1401) << "khelpcenterclient open " << url << endl; | int main(int argc, char *argv[]){ bool enableTree = false; int command = 0; QString url; // no parameters -> print usage if(argc == 1) { usage(); return 0; } // parse command line parameters for (int i = 1; i < argc; i++) { if (strcasecmp(argv[i], "configure") == 0) { command = 1; break; } else if (strcasecmp(argv[i], "-enable_tree") == 0) { enableTree = true; } else if (command == 2) // already found 'open'...this must be a url { url = argv[i]; } else if (strcasecmp( argv[i], "open" ) == 0) { command = 2; } } if (command == 0) { usage(); return 0; } KOMApplication app(argc, argv, "khelpcenterclient"); // init CORBA stuff CORBA::Object_var obj = app.orb()->bind("IDL:KHelpCenter/HelpCenterCom:1.0", "inet:localhost:8887"); if(CORBA::is_nil(obj)) { kdebug(KDEBUG_FATAL,1401,"It seems that the khelpcenter server isn't running!"); return 0; } KHelpCenter::HelpCenterCom_var server = KHelpCenter::HelpCenterCom::_narrow(obj); kdebug(KDEBUG_INFO,1401,"binding to KOM interface: IDL:KHelpCenter/HelpCenterCom:1.0"); if (command == 1) { kdebug(KDEBUG_INFO,1401,"khelpcenterclient -configure"); server->configure(); } else if (command == 2) { if (url.isEmpty()) url = "file:" + locate("html", "default/khelpcenter/main.html"); kdebug(KDEBUG_INFO,1401,"khelpcenterclient open %s", url.ascii()); server->openHelpView (url, enableTree); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6e70c325b7e97c99756efc38fc56ff93bf507450/khelpcenterclient.cpp/clean/khelpcenter/helpcenter/khelpcenterclient.cpp |
FileTypeDialog * dlg = new FileTypeDialog( mime ); dlg->setCaption( i18n("Edit File Type %1").arg(mime->name()) ); dlg->exec(); delete dlg; | dlg.setCaption( i18n("Edit File Type %1").arg(mime->name()) ); app.setMainWidget( &dlg ); dlg.show(); | int main(int argc, char ** argv){ KServiceTypeProfile::setConfigurationMode(); KLocale::setMainCatalogue("filetypes"); KAboutData aboutData( "keditfiletype", I18N_NOOP("KEditFileType"), "1.0", I18N_NOOP("KDE file type editor - simplified version for editing a single file type"), KAboutData::License_GPL, I18N_NOOP("(c) 2000, KDE developers") ); aboutData.addAuthor("Preston Brown",0, "[email protected]"); aboutData.addAuthor("David Faure",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->count() == 0) KCmdLineArgs::usage(); KMimeType::Ptr mime = KMimeType::mimeType( args->arg(0) ); if (!mime) kdFatal() << "Mimetype " << args->arg(0) << " not found" << endl; args->clear(); FileTypeDialog * dlg = new FileTypeDialog( mime ); dlg->setCaption( i18n("Edit File Type %1").arg(mime->name()) ); dlg->exec(); delete dlg; return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/43c852f25d2f536893b54a178dd095ed0a6fcf12/keditfiletype.cpp/clean/keditfiletype/keditfiletype.cpp |
return 0; | return app.exec(); | int main(int argc, char ** argv){ KServiceTypeProfile::setConfigurationMode(); KLocale::setMainCatalogue("filetypes"); KAboutData aboutData( "keditfiletype", I18N_NOOP("KEditFileType"), "1.0", I18N_NOOP("KDE file type editor - simplified version for editing a single file type"), KAboutData::License_GPL, I18N_NOOP("(c) 2000, KDE developers") ); aboutData.addAuthor("Preston Brown",0, "[email protected]"); aboutData.addAuthor("David Faure",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->count() == 0) KCmdLineArgs::usage(); KMimeType::Ptr mime = KMimeType::mimeType( args->arg(0) ); if (!mime) kdFatal() << "Mimetype " << args->arg(0) << " not found" << endl; args->clear(); FileTypeDialog * dlg = new FileTypeDialog( mime ); dlg->setCaption( i18n("Edit File Type %1").arg(mime->name()) ); dlg->exec(); delete dlg; return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/43c852f25d2f536893b54a178dd095ed0a6fcf12/keditfiletype.cpp/clean/keditfiletype/keditfiletype.cpp |
exit(0); | return 0; | int main(int argc, char *argv[]){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE HelpCenter"), HELPCENTER_VERSION, I18N_NOOP("The KDE Help Center"), KAboutData::License_GPL, "(c) 1999-2000, Matthias Elter"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); KApplication app( false, false ); // no GUI in this process app.dcopClient()->attach(); Listener listener; QCString dcopService; QString error; // try to connect to an already running konqueror, if one exists QCStringList apps = app.dcopClient()->registeredApplications(); QCStringList::ConstIterator it; for (it = apps.begin(); it != apps.end(); ++it) if ((*it).left(9) == "konqueror") { createHelpWindow(*it); exit(0); } // run a new konqueror instance app.dcopClient()->setNotifications( true ); QObject::connect( app.dcopClient(), SIGNAL( applicationRegistered( const QCString& ) ), &listener, SLOT( slotAppRegistered( const QCString & ) ) ); if (app.startServiceByDesktopName("konqueror", QString::fromLatin1("--silent"), &error)) { warning("Could not launch browser:\n%s\n", error.local8Bit().data()); return 1; } app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4acacb7c7fb6420cf541f6dc5c6ab525298e4f0f/khc_main.cc/buggy/khelpcenter/khc_main.cc |
int main(int argc, char *argv[]){ KOMApplication app( argc, argv ); // create a KdedInstance object, which takes care about connecting to kded // and providing a trader and an activator KdedInstance kded(argc, argv, komapp_orb); // get a pointer to the activator KActivator *activator = kded.kactivator(); // now we register our service // usually we query the trader for a certain service and use the data // of the kservice offer from the trader to register the service, but since // our service is not registered with the trader we do the registration at // the activator "manually" QStringList repoIds; repoIds.append( "IDL:KHelpCenter/HelpWindowFactory:1.0#KHelpCenter" ); // now let's really register the service // this will make the activator register the service at the IMR // (note: if the service is already registered then this function will // return "false" (and create some debug output ;) ) activator->registerService( "KHelpCenter", "shared", repoIds, "khelpcenterd" ); // let's activate a service in the server // this function returns a "virtual" object reference, which means that the // server starts "lazy" upon demand. In fact we (client) don't have to care // about this, but it's a good thing to have this in mind. // this virtual reference turns into a "real" reference when we do an invokation. // the activator in kded will then either connect to a running server or start a // new one. But we don't really have to care about this :-) , we are just // happy with our functional object reference CORBA::Object_var obj = activator->activateService( "KHelpCenter", "IDL:KHelpCenter/HelpWindowFactory:1.0", "KHelpCenter" ); assert( !CORBA::is_nil( obj ) ); KHelpCenter::HelpWindowFactory_var factory = KHelpCenter::HelpWindowFactory::_narrow( obj ); assert( !CORBA::is_nil( factory ) ); KHelpCenter::HelpWindow_var view = factory->create(); assert(!CORBA::is_nil(view)); if(argc == 2) { QString url = argv[1]; view->open(url); } // unregister our service // this make the service unavailable for any other clients, since the server // entry in the IMR gets removed // if you want to play around a little bit you can do the following: // * comment this line out, to keep the service registered upon exit // * comment the next line out, too, to avoid our explicit server shutdown // This will lead to the following situation: // when you call this client example app the first time then myservice_impl // gets started by kded. the next time you run ./client, the previous, still // active, server will be used :-) // activator->unregisterService( "MyService" ); // explicitly shut the server down (see myservice_impl.cc) //comp->exit(); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4817a5d63c6f9c040d2fd85e8d6e865b4d41b04f/khelpcenterclient.cpp/clean/khelpcenter/khelpcenterclient.cpp |
||
int main(int argc, char *argv[]){ KOMApplication app( argc, argv ); // create a KdedInstance object, which takes care about connecting to kded // and providing a trader and an activator KdedInstance kded(argc, argv, komapp_orb); // get a pointer to the activator KActivator *activator = kded.kactivator(); // now we register our service // usually we query the trader for a certain service and use the data // of the kservice offer from the trader to register the service, but since // our service is not registered with the trader we do the registration at // the activator "manually" QStringList repoIds; repoIds.append( "IDL:KHelpCenter/HelpWindowFactory:1.0#KHelpCenter" ); // now let's really register the service // this will make the activator register the service at the IMR // (note: if the service is already registered then this function will // return "false" (and create some debug output ;) ) activator->registerService( "KHelpCenter", "shared", repoIds, "khelpcenterd" ); // let's activate a service in the server // this function returns a "virtual" object reference, which means that the // server starts "lazy" upon demand. In fact we (client) don't have to care // about this, but it's a good thing to have this in mind. // this virtual reference turns into a "real" reference when we do an invokation. // the activator in kded will then either connect to a running server or start a // new one. But we don't really have to care about this :-) , we are just // happy with our functional object reference CORBA::Object_var obj = activator->activateService( "KHelpCenter", "IDL:KHelpCenter/HelpWindowFactory:1.0", "KHelpCenter" ); assert( !CORBA::is_nil( obj ) ); KHelpCenter::HelpWindowFactory_var factory = KHelpCenter::HelpWindowFactory::_narrow( obj ); assert( !CORBA::is_nil( factory ) ); KHelpCenter::HelpWindow_var view = factory->create(); assert(!CORBA::is_nil(view)); if(argc == 2) { QString url = argv[1]; view->open(url); } // unregister our service // this make the service unavailable for any other clients, since the server // entry in the IMR gets removed // if you want to play around a little bit you can do the following: // * comment this line out, to keep the service registered upon exit // * comment the next line out, too, to avoid our explicit server shutdown // This will lead to the following situation: // when you call this client example app the first time then myservice_impl // gets started by kded. the next time you run ./client, the previous, still // active, server will be used :-) // activator->unregisterService( "MyService" ); // explicitly shut the server down (see myservice_impl.cc) //comp->exit(); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4817a5d63c6f9c040d2fd85e8d6e865b4d41b04f/khelpcenterclient.cpp/clean/khelpcenter/khelpcenterclient.cpp |
||
int main(int argc, char *argv[]){ KOMApplication app( argc, argv ); // create a KdedInstance object, which takes care about connecting to kded // and providing a trader and an activator KdedInstance kded(argc, argv, komapp_orb); // get a pointer to the activator KActivator *activator = kded.kactivator(); // now we register our service // usually we query the trader for a certain service and use the data // of the kservice offer from the trader to register the service, but since // our service is not registered with the trader we do the registration at // the activator "manually" QStringList repoIds; repoIds.append( "IDL:KHelpCenter/HelpWindowFactory:1.0#KHelpCenter" ); // now let's really register the service // this will make the activator register the service at the IMR // (note: if the service is already registered then this function will // return "false" (and create some debug output ;) ) activator->registerService( "KHelpCenter", "shared", repoIds, "khelpcenterd" ); // let's activate a service in the server // this function returns a "virtual" object reference, which means that the // server starts "lazy" upon demand. In fact we (client) don't have to care // about this, but it's a good thing to have this in mind. // this virtual reference turns into a "real" reference when we do an invokation. // the activator in kded will then either connect to a running server or start a // new one. But we don't really have to care about this :-) , we are just // happy with our functional object reference CORBA::Object_var obj = activator->activateService( "KHelpCenter", "IDL:KHelpCenter/HelpWindowFactory:1.0", "KHelpCenter" ); assert( !CORBA::is_nil( obj ) ); KHelpCenter::HelpWindowFactory_var factory = KHelpCenter::HelpWindowFactory::_narrow( obj ); assert( !CORBA::is_nil( factory ) ); KHelpCenter::HelpWindow_var view = factory->create(); assert(!CORBA::is_nil(view)); if(argc == 2) { QString url = argv[1]; view->open(url); } // unregister our service // this make the service unavailable for any other clients, since the server // entry in the IMR gets removed // if you want to play around a little bit you can do the following: // * comment this line out, to keep the service registered upon exit // * comment the next line out, too, to avoid our explicit server shutdown // This will lead to the following situation: // when you call this client example app the first time then myservice_impl // gets started by kded. the next time you run ./client, the previous, still // active, server will be used :-) // activator->unregisterService( "MyService" ); // explicitly shut the server down (see myservice_impl.cc) //comp->exit(); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4817a5d63c6f9c040d2fd85e8d6e865b4d41b04f/khelpcenterclient.cpp/clean/khelpcenter/khelpcenterclient.cpp |
||
int main(int argc, char *argv[]){ KOMApplication app( argc, argv ); // create a KdedInstance object, which takes care about connecting to kded // and providing a trader and an activator KdedInstance kded(argc, argv, komapp_orb); // get a pointer to the activator KActivator *activator = kded.kactivator(); // now we register our service // usually we query the trader for a certain service and use the data // of the kservice offer from the trader to register the service, but since // our service is not registered with the trader we do the registration at // the activator "manually" QStringList repoIds; repoIds.append( "IDL:KHelpCenter/HelpWindowFactory:1.0#KHelpCenter" ); // now let's really register the service // this will make the activator register the service at the IMR // (note: if the service is already registered then this function will // return "false" (and create some debug output ;) ) activator->registerService( "KHelpCenter", "shared", repoIds, "khelpcenterd" ); // let's activate a service in the server // this function returns a "virtual" object reference, which means that the // server starts "lazy" upon demand. In fact we (client) don't have to care // about this, but it's a good thing to have this in mind. // this virtual reference turns into a "real" reference when we do an invokation. // the activator in kded will then either connect to a running server or start a // new one. But we don't really have to care about this :-) , we are just // happy with our functional object reference CORBA::Object_var obj = activator->activateService( "KHelpCenter", "IDL:KHelpCenter/HelpWindowFactory:1.0", "KHelpCenter" ); assert( !CORBA::is_nil( obj ) ); KHelpCenter::HelpWindowFactory_var factory = KHelpCenter::HelpWindowFactory::_narrow( obj ); assert( !CORBA::is_nil( factory ) ); KHelpCenter::HelpWindow_var view = factory->create(); assert(!CORBA::is_nil(view)); if(argc == 2) { QString url = argv[1]; view->open(url); } // unregister our service // this make the service unavailable for any other clients, since the server // entry in the IMR gets removed // if you want to play around a little bit you can do the following: // * comment this line out, to keep the service registered upon exit // * comment the next line out, too, to avoid our explicit server shutdown // This will lead to the following situation: // when you call this client example app the first time then myservice_impl // gets started by kded. the next time you run ./client, the previous, still // active, server will be used :-) // activator->unregisterService( "MyService" ); // explicitly shut the server down (see myservice_impl.cc) //comp->exit(); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4817a5d63c6f9c040d2fd85e8d6e865b4d41b04f/khelpcenterclient.cpp/clean/khelpcenter/khelpcenterclient.cpp |
||
int main( int argc, char *argv[] ){ // David, 05/03/2000 KAboutData aboutData( "kstart", I18N_NOOP("KStart"), KSTART_VERSION, I18N_NOOP("" "Utility to launch applications with special window properties \n" "such as iconified, maximized, a certain virtual desktop, a special decoration\n" "and so on." ), KAboutData::License_GPL, "(C) 1997-2000 Matthias Ettrich ([email protected])" ); aboutData.addAuthor( "Matthias Ettrich", 0, "[email protected]" ); aboutData.addAuthor( "David Faure", 0, "[email protected]" ); aboutData.addAuthor( "Richard J. Moore", 0, "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if ( args->count() == 0 ) KCmdLineArgs::usage(i18n("No command specified")); // Perhaps we should use a konsole-like solution here (shell, list of args...) for(int i=0; i < args->count(); i++) command += QCString(args->arg(i)) + " "; kwinmodule = new KWinModule; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; if ( args->isSet ( "currentdesktop") ) desktop = kwinmodule->currentDesktop(); windowtitle = args->getOption( "window" ); windowclass = args->getOption( "windowclass" ); if( windowclass ) windowclass = windowclass.lower(); if( windowtitle.isEmpty() && windowclass.isEmpty()) kdWarning() << "Omitting both --window and --windowclass arguments is not recommended" << endl; QCString s = args->getOption( "type" ); if ( !s.isEmpty() ) { s = s.lower(); if ( s == "desktop" ) windowtype = NET::Desktop; else if ( s == "dock" ) windowtype = NET::Dock; else if ( s == "tool" ) windowtype = NET::Tool; else if ( s == "menu" ) windowtype = NET::Menu; else if ( s == "dialog" ) windowtype = NET::Dialog; else if ( s == "override" ) windowtype = NET::Override; else if ( s == "topmenu" ) windowtype = NET::TopMenu; else windowtype = NET::Normal; } if ( args->isSet( "keepabove" ) ) { state |= NET::KeepAbove; mask |= NET::KeepAbove; } else if ( args->isSet( "keepbelow" ) ) { state |= NET::KeepBelow; mask |= NET::KeepBelow; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } if ( args->isSet( "skippager" ) ) { state |= NET::SkipPager; mask |= NET::SkipPager; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } if ( args->isSet("maximize-vertically") ) { state |= NET::MaxVert; mask |= NET::MaxVert; } if ( args->isSet("maximize-horizontally") ) { state |= NET::MaxHoriz; mask |= NET::MaxHoriz; } iconify = args->isSet("iconify"); toSysTray = args->isSet("tosystray"); if ( args->isSet("fullscreen") ) { NETRootInfo i( qt_xdisplay(), NET::Supported ); if( i.isSupported( NET::FullScreen )) { state |= NET::FullScreen; mask |= NET::FullScreen; } else { windowtype = NET::Override; fullscreen = true; } } fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/3234d8e32f6a5f92fce44f5d38d612c3a641125d/kstart.cpp/clean/kstart/kstart.cpp |
||
command += QCString(args->arg(i)) + " "; | proc << args->arg(i); | int main( int argc, char *argv[] ){ // David, 05/03/2000 KAboutData aboutData( "kstart", I18N_NOOP("KStart"), KSTART_VERSION, I18N_NOOP("" "Utility to launch applications with special window properties \n" "such as iconified, maximized, a certain virtual desktop, a special decoration\n" "and so on." ), KAboutData::License_GPL, "(C) 1997-2000 Matthias Ettrich ([email protected])" ); aboutData.addAuthor( "Matthias Ettrich", 0, "[email protected]" ); aboutData.addAuthor( "David Faure", 0, "[email protected]" ); aboutData.addAuthor( "Richard J. Moore", 0, "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if ( args->count() == 0 ) KCmdLineArgs::usage(i18n("No command specified")); // Perhaps we should use a konsole-like solution here (shell, list of args...) for(int i=0; i < args->count(); i++) command += QCString(args->arg(i)) + " "; kwinmodule = new KWinModule; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; if ( args->isSet ( "currentdesktop") ) desktop = kwinmodule->currentDesktop(); windowtitle = args->getOption( "window" ); windowclass = args->getOption( "windowclass" ); if( windowclass ) windowclass = windowclass.lower(); if( windowtitle.isEmpty() && windowclass.isEmpty()) kdWarning() << "Omitting both --window and --windowclass arguments is not recommended" << endl; QCString s = args->getOption( "type" ); if ( !s.isEmpty() ) { s = s.lower(); if ( s == "desktop" ) windowtype = NET::Desktop; else if ( s == "dock" ) windowtype = NET::Dock; else if ( s == "tool" ) windowtype = NET::Tool; else if ( s == "menu" ) windowtype = NET::Menu; else if ( s == "dialog" ) windowtype = NET::Dialog; else if ( s == "override" ) windowtype = NET::Override; else if ( s == "topmenu" ) windowtype = NET::TopMenu; else windowtype = NET::Normal; } if ( args->isSet( "keepabove" ) ) { state |= NET::KeepAbove; mask |= NET::KeepAbove; } else if ( args->isSet( "keepbelow" ) ) { state |= NET::KeepBelow; mask |= NET::KeepBelow; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } if ( args->isSet( "skippager" ) ) { state |= NET::SkipPager; mask |= NET::SkipPager; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } if ( args->isSet("maximize-vertically") ) { state |= NET::MaxVert; mask |= NET::MaxVert; } if ( args->isSet("maximize-horizontally") ) { state |= NET::MaxHoriz; mask |= NET::MaxHoriz; } iconify = args->isSet("iconify"); toSysTray = args->isSet("tosystray"); if ( args->isSet("fullscreen") ) { NETRootInfo i( qt_xdisplay(), NET::Supported ); if( i.isSupported( NET::FullScreen )) { state |= NET::FullScreen; mask |= NET::FullScreen; } else { windowtype = NET::Override; fullscreen = true; } } fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/3234d8e32f6a5f92fce44f5d38d612c3a641125d/kstart.cpp/clean/kstart/kstart.cpp |
KGlobal::locale()->insertCatalogue("kio_media"); | int main(int argc, char **argv){ KCmdLineArgs::init(argc, argv, "kio_media_mounthelper", "kio_media_mounthelper", "kio_media_mounthelper", "0.1"); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); if (KCmdLineArgs::parsedArgs()->count()==0) KCmdLineArgs::usage(); KApplication *app = new MountHelper(); KGlobal::locale()->insertCatalogue("kio_media"); app->dcopClient()->attach(); app->exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/cc5e22873709c19a7ecd18f239bde6656e143697/kio_media_mounthelper.cpp/buggy/kioslave/media/mounthelper/kio_media_mounthelper.cpp |
|
QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
|
for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) | for (int i = 1; i < argc; i++) | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]); | printf("%d: %s\n", i, argv[i]); | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) { | if ( qgis->addRasterLayer(argv[i]) ) { continue; } else if ( qgis->addLayer(argv[i]) ) { continue; } else { | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
printf("OK\n"); | std::cerr << argv[i] << " is not a recognized file\n"; | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
myArgString = argv[myIteratorInt]; #ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count()); #endif myFileStringList.append(myArgString); } } #ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count()); #endif if (!myFileStringList.isEmpty()) { #ifdef QGISDEBUG printf("Loading vector files...\n"); #endif qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); | } | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef QGISDEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef QGISDEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef QGISDEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef QGISDEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef QGISDEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ba833cdfbb424ffa823ee5bd01fc21ea40bb3b4b/main.cpp/buggy/src/main.cpp |
int main(int argc, char **argv) { cerr << "hi there" << endl; if (argc > 1) { int d = atoi(argv[1]); if (d > 0) g_conf.debug = d; cerr << " debug level " << d << endl; } MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // local config settings g_conf.num_client = g_conf.num_fakeclient; // to fool mds, hack gross // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); mds[i]->init(); } // create osds OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); osd[i]->init(); } // create clients FakeClient *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { client[i] = new FakeClient(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(i)), g_conf.fakeclient_requests); client[i]->init(); } // seed initial requests for (int i=0; i<NUMCLIENT; i++) //for (int i=0; i<1; i++) client[i]->issue_request(); // loop fakemessenger_do_loop(); //mds[0]->shutdown_start(); //fakemessenger_do_loop(); // if (argc > 1 && strcmp(argv[1], "nocheck") == 0) { cerr << "---- nocheck" << endl; } else { cout << "---- check ----" << endl; for (int i=0; i<NUMMDS; i++) mds[i]->mdcache->shutdown_pass(); } // cleanup cout << "cleanup" << endl; for (int i=0; i<NUMMDS; i++) { if (mds[i]->shutdown_final() == 0) { //cout << "clean shutdown of mds " << i << endl; delete mds[i]; } else { cout << "problems shutting down mds " << i << endl; } } for (int i=0; i<NUMOSD; i++) { if (osd[i]->shutdown() == 0) { //cout << "clean shutdown of osd " << i << endl; delete osd[i]; } else { cout << "problems shutting down osd " << i << endl; } } for (int i=0; i<NUMCLIENT; i++) { if (client[i]->shutdown() == 0) { //cout << "clean shutdown of client " << i << endl; delete client[i]; } else { cout << "problems shutting down client " << i << endl; } } delete mdc; cout << "done." << endl; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/df500177ae6e5046343fde6b67f1721e19faee15/fakemds.cc/clean/ceph/test/fakemds.cc |
||
client[i]->issue_request(); | client[i]->mount(); | int main(int argc, char **argv) { cerr << "hi there" << endl; if (argc > 1) { int d = atoi(argv[1]); if (d > 0) g_conf.debug = d; cerr << " debug level " << d << endl; } MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // local config settings g_conf.num_client = g_conf.num_fakeclient; // to fool mds, hack gross // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); mds[i]->init(); } // create osds OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); osd[i]->init(); } // create clients FakeClient *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { client[i] = new FakeClient(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(i)), g_conf.fakeclient_requests); client[i]->init(); } // seed initial requests for (int i=0; i<NUMCLIENT; i++) //for (int i=0; i<1; i++) client[i]->issue_request(); // loop fakemessenger_do_loop(); //mds[0]->shutdown_start(); //fakemessenger_do_loop(); // if (argc > 1 && strcmp(argv[1], "nocheck") == 0) { cerr << "---- nocheck" << endl; } else { cout << "---- check ----" << endl; for (int i=0; i<NUMMDS; i++) mds[i]->mdcache->shutdown_pass(); } // cleanup cout << "cleanup" << endl; for (int i=0; i<NUMMDS; i++) { if (mds[i]->shutdown_final() == 0) { //cout << "clean shutdown of mds " << i << endl; delete mds[i]; } else { cout << "problems shutting down mds " << i << endl; } } for (int i=0; i<NUMOSD; i++) { if (osd[i]->shutdown() == 0) { //cout << "clean shutdown of osd " << i << endl; delete osd[i]; } else { cout << "problems shutting down osd " << i << endl; } } for (int i=0; i<NUMCLIENT; i++) { if (client[i]->shutdown() == 0) { //cout << "clean shutdown of client " << i << endl; delete client[i]; } else { cout << "problems shutting down client " << i << endl; } } delete mdc; cout << "done." << endl; return 0;} | 2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/df500177ae6e5046343fde6b67f1721e19faee15/fakemds.cc/clean/ceph/test/fakemds.cc |
#ifdef DEBUG | #ifdef QGISDEBUG | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef DEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef DEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef DEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef DEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/f5337a7d69da9483875e8f1c066e99faa6d80403/main.cpp/buggy/src/main.cpp |
#ifdef DEBUG | #ifdef QGISDEBUG | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef DEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef DEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef DEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef DEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/f5337a7d69da9483875e8f1c066e99faa6d80403/main.cpp/buggy/src/main.cpp |
#ifdef DEBUG | #ifdef QGISDEBUG | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef DEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef DEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef DEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef DEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/f5337a7d69da9483875e8f1c066e99faa6d80403/main.cpp/buggy/src/main.cpp |
#ifdef DEBUG | #ifdef QGISDEBUG | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef DEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef DEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef DEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef DEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/f5337a7d69da9483875e8f1c066e99faa6d80403/main.cpp/buggy/src/main.cpp |
#ifdef DEBUG | #ifdef QGISDEBUG | int main(int argc, char *argv[]){ QString myArgString; QFile myQFile; QStringList myFileStringList; bool myFileExistsFlag; QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (argc == 2) { QString translation = "qgis_" + QString(argv[1]); tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) {#ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]);#endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if (myFileExistsFlag) {#ifdef DEBUG printf("OK\n");#endif myArgString = argv[myIteratorInt];#ifdef DEBUG printf("Layer count: %d\n", myFileStringList.count());#endif myFileStringList.append(myArgString); } }#ifdef DEBUG printf("rCount: %d\n", myFileStringList.count());#endif if (!myFileStringList.isEmpty()) {#ifdef DEBUG printf("Loading vector files...\n");#endif //try to add all these layers - any unsupported file types will be refected automatically qgis->addRasterLayer(myFileStringList); qgis->addLayer(myFileStringList); } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/f5337a7d69da9483875e8f1c066e99faa6d80403/main.cpp/buggy/src/main.cpp |
KLocale::setMainCatalogue(0); | int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } // locate the desktop file QStringList files; if (args->arg(0)[0] == '/') files.append(args->arg(0)); else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; if (files.count() <= 0) { cerr << i18n("Module not found!") << endl; return -1; } args->clear(); // load the module ModuleInfo info(files[0]); KCModule *module = ModuleLoader::module(info, 0); if (module) { // create the dialog KCDialog dlg(module, info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // run the dialog return dlg.exec(); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/11e713d7d5156bd3e7c4d97e363cd0d05dea9726/kcmshell.cpp/buggy/kcontrol/kcontrol/kcmshell.cpp |
|
QString tmp = conf->readEntry("AutostartOnKDEStartup", "0"); if (tmp == "0" && (strcmp(argv[1], "--kdestartup") == 0)) | QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) | int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "0"); if (tmp == "0" && (strcmp(argv[1], "--kdestartup") == 0)) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1669e57cc1672bc9c46e9756ec2445cf6851d512/main.cpp/buggy/khelpcenter/kwelcome/main.cpp |
int c; | qInstallMsgHandler(msgHandler); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << Usage << TryHelp << endl; | printf(Usage); printf(TryHelp); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } | if (pw == 0L) qFatal("User %s does not exist", s.latin1()); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << Usage << TryHelp << endl; | printf(Usage); printf(TryHelp); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << Usage << TryHelp << endl; | printf(Usage); printf(TryHelp); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; | printf("kdesu version %s\n", Version); printf("\n"); printf(" Copyright (C) 1998 Pietro Iglio <[email protected]>\n"); printf(" Copyright (C) 1999 Geert Jansen %s", Email); printf("\n"); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; | printf(Usage); printf("Runs a command as another user.\n"); printf("\n"); printf("Options:\n"); printf(" -c COMMAND Run command COMMAND. The entire command\n"); printf(" line has to be passed as a single argument.\n"); printf(" -f FILE Run command as root if file specified by FILE\n"); printf(" is not writeable under current uid.\n"); printf(" -n Do not keep password\n"); printf(" -s Stop the daemon (forgets all passwords)\n"); printf(" -t Enable terminal output (no password keeping).\n"); printf(" -q Be quiet (shows no warnings)\n"); printf(" -d Show debug information\n"); printf(" -v Show version information\n"); printf("\n"); printf("Please report bugs to %s\n", Email); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } | if (client.ping() == -1) qFatal("Daemon not running -- nothing to stop"); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << "Daemon stopped\n"; | printf("Daemon stopped\n"); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
error("Could not stop daemon"); exit(1); | qFatal("Could not stop daemon"); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << Usage << TryHelp << endl; | printf(Usage); printf(TryHelp); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
cout << Usage << TryHelp << endl; | printf(Usage); printf(TryHelp); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } | if (!fi.exists()) qFatal("File does not exist: %s", file.latin1()); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } | if (setrlimit(RLIMIT_CORE, &rlim)) qFatal("rlimit(): %s", strerror(errno)); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); | KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
error("Cannot connect to daemon -- not keeping password"); | qWarning("Cannot connect to daemon -- not keeping password"); | int main(int argc, char *argv[]){ int c; QString command, file; bool keep = true; bool terminal = false; KStartParams parm(argc, argv); QString s; // Parse user name argument uid_t uid; QString user; int i=0; s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } if (s.at(0) != '-') { struct passwd *pw = getpwnam(s.latin1()); if (pw == 0L) { error("User %s does not exist", s.latin1()); exit(1); } user = s; uid = pw->pw_uid; s = parm.get(i++); } else { user = "root"; uid = 0; } // Parse options while (s != "-c") { if (s.at(0) != '-') { cout << Usage << TryHelp << endl; exit(1); } bool next = false; for (int j=1; j<s.length(); j++) { switch (s.at(j).latin1()) { case 'f': file = parm.get(i++); if (file.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } next = true; break; case 't': terminal = true; break; case 'n': keep = false; break; case 'q': _show_dbg = 0; _show_wrn = 0; break; case 'd': _show_dbg++; break; // Exiting comand from here case 'v': cerr << "kdesu version " << Version << endl; cerr << endl; cerr << " Copyright (C) 1998 Pietro Iglio <[email protected]>\n"; cerr << " Copyright (C) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'h': cerr << Usage; cerr << "Runs a command as another user.\n"; cerr << endl; cerr << "Options:\n"; cerr << " -c COMMAND Run command COMMAND. The entire command\n"; cerr << " line has to be passed as a single argument.\n"; cerr << " -f FILE Run command as root if file specified by FILE\n"; cerr << " is not writeable under current uid.\n"; cerr << " -n Do not keep password\n"; cerr << " -s Stop the daemon (forgets all passwords)\n"; cerr << " -t Enable terminal output (no password keeping).\n"; cerr << " -q Be quiet (shows no warnings)\n"; cerr << " -d Show debug information\n"; cerr << " -v Show version information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 's': { KDEsuClient client; if (client.ping() == -1) { error("Daemon not running -- nothing to stop"); exit(1); } if (client.stopServer() != -1) { cout << "Daemon stopped\n"; return 0; } error("Could not stop daemon"); exit(1); } } if (next) break; } s = parm.get(i++); if (s.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } } // Parse command command = parm.get(i++); if (command.isEmpty()) { cout << Usage << TryHelp << endl; exit(1); } while (!(s = parm.get(i++)).isEmpty()) { command += " "; command += s; } // Don't use su if we're don't need to. bool change_uid = (getuid() != uid); // If file is not writeable, change uid if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); } QFileInfo fi(file); if (!fi.exists()) { error("File does not exist: %s", file.latin1()); exit(1); } change_uid = !fi.isWritable(); } if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Try to exec the command with kdesud. if (keep && !terminal) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); if (client.exec(command) != -1) return 0; } else // The user has to enter a password and this very probably // gives enough time to start up the daemon. keep = (client.startServer() != -1); } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { xerror("rlimit(): %s"); exit(1); } // From here, we need the GUI: create a KApplication KApplication *app = new KApplication(argc, argv, "kdesu"); // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Common"); QString val = config->readEntry("EchoMode", "x"); int echo_mode; if (val == "OneStar") echo_mode = OneStar; else if (val == "ThreeStars") echo_mode = ThreeStars; else if (val == "NoStars") echo_mode = NoStars; else echo_mode = defEchomode; bool keep_cfg = config->readBoolEntry("KeepPassword", defKeep); int pw_timeout = config->readNumEntry("KeepPasswordTimeout", defTimeout); // Start the dialog QString txt; if (user == "root") txt = i18n("The action you requested needs root priviliges.\n" "Please enter root's password below or click\n" "Ignore to continue with your current priviliges."); else txt = i18n("The action you requested needs additional priviliges.\n" "Please enter the password for \"%1\" below or click\n" "Ignore to continue with your current privileges.").arg(user); KPasswordDlg *pwDlg = new KPasswordDlg(txt, command, user, ((keep&&!terminal) ? 1+keep_cfg : 0)); pwDlg->setEchoMode(echo_mode); pwDlg->exec(); char *pass = new char[KPasswordEdit::PassLen]; switch (pwDlg->result()) { case KPasswordDlg::Accepted: strcpy(pass, pwDlg->getPass()); change_uid = true; break; case KPasswordDlg::Rejected: return 0; case KPasswordDlg::AsUser: change_uid = false; break; } keep = pwDlg->keepPass(); delete pwDlg; // This destroys the Qt event loop and makes sure the dialog goes away. delete app; if (!change_uid) { UserProcess proc(command); return proc.exec(); } // Change uid if (keep) { KDEsuClient client; if (client.ping() != -1) { client.setUser(user); client.setPass(pass, pw_timeout); return client.exec(command); } else error("Cannot connect to daemon -- not keeping password"); } SuProcess proc; proc.setCommand(command); proc.setUser(user); proc.setTerminal(terminal); proc.setErase(true); return proc.exec(pass);} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/5572da27796be4b14fe2b1122a9b1aa8a9a7a754/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
||
if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } | int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
|
FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); | FileProps *props = new FileProps( args->url(i).path(), groupsToUse ); | int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
else if ( !quiet ) cerr << args->arg(i) << ": " << | else { if ( !quiet ) { cerr << args->arg(i) << ": " << | int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
||
cout.flush(); | int main( int argc, char **argv ){ KAboutData about( "kfile", I18N_NOOP( "kfile" ), KFILEVERSION, I18N_NOOP("A commandline tool to read and modify metadata of files." ), KAboutData::License_LGPL, "(c) 2002, Carsten Pfeiffer", 0 /*text*/, "http://devel-home.kde.org/~pfeiffer/", "[email protected]" ); about.addAuthor( "Carsten Pfeiffer", 0, "[email protected]", "http://devel-home.kde.org/~pfeiffer/" ); KCmdLineArgs::init( argc, argv, &about ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); bool useGUI = args->isSet( "dialog" ); KApplication app( useGUI, useGUI ); QPtrList<FileProps> m_props; m_props.setAutoDelete( true ); bool quiet = args->isSet( "quiet" ); if ( args->isSet( "supportedMimetypes" ) ) printSupportedMimeTypes(); int files = args->count(); if ( files == 0 ) KCmdLineArgs::usage( i18n("No files specified") ); // exit()s QString mimeType; for ( int i = 0; i < files; i++ ) { if ( args->isSet( "dialog" ) ) { showPropertiesDialog( args ); return true; } if ( args->isSet( "mimetype" ) ) printMimeTypes( args ); FileProps *props = new FileProps( args->arg(i), args->url(i).path() ); if ( props->isValid() ) m_props.append( props ); else if ( !quiet ) cerr << args->arg(i) << ": " << i18n("Cannot determine metadata").local8Bit() << endl; } processMetaDataOptions( m_props, args ); return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/aa809797132f6870b8cce0d21ec4b9e98669bd7c/fileprops.cpp/buggy/kfile/fileprops.cpp |
|
KCDialog dlg(module, QString::null, 0, 0, true); | KCDialog dlg(module, info.docPath(), 0, 0, true); | int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } // locate the desktop file QStringList files; if (args->arg(0)[0] == '/') files.append(args->arg(0)); else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; if (files.count() <= 0) { cerr << i18n("Module not found!") << endl; return -1; } args->clear(); // load the module ModuleInfo info(files[0]); KCModule *module = ModuleLoader::module(info, 0); if (module) { // create the dialog KCDialog dlg(module, QString::null, 0, 0, true); dlg.setCaption(info.name()); // run the dialog return dlg.exec(); } return 0;} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/4c4acc0573061afe3b2a847c5d22ccb1d277498a/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp |
uiserver = new UIServer; | uiserver = new UIServer(); | int main(int argc, char **argv){ KLocale::setMainCatalogue("kdelibs"); // GS 5/2001 - I changed the name to "KDE" to make it look better // in the titles of dialogs which are displayed. KAboutData aboutdata("kio_uiserver", I18N_NOOP("KDE"), "0.8", I18N_NOOP("KDE Progress Information UI Server"), KAboutData::License_GPL, "(C) 2000, David Faure & Matt Koss"); // Who's the maintainer ? :) aboutdata.addAuthor("David Faure",I18N_NOOP("Developer"),"[email protected]"); aboutdata.addAuthor("Matej Koss",I18N_NOOP("Developer"),"[email protected]"); KCmdLineArgs::init( argc, argv, &aboutdata ); // KCmdLineArgs::addCmdLineOptions( options ); KUniqueApplication::addCmdLineOptions(); if (!KUniqueApplication::start()) { kdDebug(7024) << "kio_uiserver is already running!" << endl; return (0); } KUniqueApplication app; // This app is started automatically, no need for session management app.disableSessionManagement(); app.dcopClient()->setDaemonMode( true ); uiserver = new UIServer; app.setMainWidget( uiserver ); return app.exec();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/885fd51024359f62229ada971e2a460b3167aeeb/uiserver.cpp/clean/kuiserver/uiserver.cpp |
int main(int argc, char *argv[]){ QApplication a(argc, argv); PluginGui *myPluginGui=new PluginGui(); a.setMainWidget(myPluginGui); myPluginGui->show(); return a.exec(); return EXIT_SUCCESS;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/3144fa49c2ce17193164da8b10eea05a682b10d1/main.cpp/buggy/plugins/gps_importer/main.cpp |
||
int main(int argc, char *argv[]){ QApplication a(argc, argv); PluginGui *myPluginGui=new PluginGui(); a.setMainWidget(myPluginGui); myPluginGui->show(); return a.exec(); return EXIT_SUCCESS;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/3144fa49c2ce17193164da8b10eea05a682b10d1/main.cpp/buggy/plugins/gps_importer/main.cpp |
||
#endif | int main(int , char **){ signal(SIGCHLD, IOProtocol::sigchld_handler); signal(SIGSEGV, IOProtocol::sigsegv_handler); Connection parent( 0, 1 ); POP3Protocol pop3( &parent ); pop3.dispatchLoop();} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/9f871ae5b51ff6eff29f857009124c805b49f5a9/pop3.cc/buggy/kioslave/pop3/pop3.cc |
|
{"includedir", no_argument, 0, 'i'}, {"libdir", no_argument, 0, 'l'}, | {"cflags", no_argument, 0, 'c'}, {"libs", no_argument, 0, 'l'}, {"plugindir", no_argument, 0, 'w'}, | int main(int argc, char **argv){ int optionChar; // options structure static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"prefix", no_argument, 0, 'p'}, {"bindir", no_argument, 0, 'b'}, {"includedir", no_argument, 0, 'i'}, {"libdir", no_argument, 0, 'l'}, {0, 0, 0, 0} }; // If no argument is given, show hint if(argc == 1) { std::cout << "qgis_config: argument required" << std::endl; std::cout << "Try \"qgis_config --help\" for more information." << std::endl; }else { // One or more arguments supplied while (1) { /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "pbil", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 'p': std::cout << PREFIX << std::endl; break; case 'b': std::cout << BIN_DIR << std::endl; break; case 'i': std::cout << INCLUDE_DIR << std::endl; break; case 'l': std::cout << LIB_DIR << std::endl; break; case 'h': usage(); return 1; break; default: std::cout << "Try \"qgis_config --help\" for more information." << std::endl; return 1; } } } // return success return 0;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/58aafaf0551c1f10cc113ebd20d1cccab4ad369e/qgis_config.cpp/clean/tools/qgis_config/qgis_config.cpp |
optionChar = getopt_long (argc, argv, "pbil", | optionChar = getopt_long (argc, argv, "pbclw", | int main(int argc, char **argv){ int optionChar; // options structure static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"prefix", no_argument, 0, 'p'}, {"bindir", no_argument, 0, 'b'}, {"includedir", no_argument, 0, 'i'}, {"libdir", no_argument, 0, 'l'}, {0, 0, 0, 0} }; // If no argument is given, show hint if(argc == 1) { std::cout << "qgis_config: argument required" << std::endl; std::cout << "Try \"qgis_config --help\" for more information." << std::endl; }else { // One or more arguments supplied while (1) { /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "pbil", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 'p': std::cout << PREFIX << std::endl; break; case 'b': std::cout << BIN_DIR << std::endl; break; case 'i': std::cout << INCLUDE_DIR << std::endl; break; case 'l': std::cout << LIB_DIR << std::endl; break; case 'h': usage(); return 1; break; default: std::cout << "Try \"qgis_config --help\" for more information." << std::endl; return 1; } } } // return success return 0;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/58aafaf0551c1f10cc113ebd20d1cccab4ad369e/qgis_config.cpp/clean/tools/qgis_config/qgis_config.cpp |
case 'i': std::cout << INCLUDE_DIR << std::endl; | case 'c': std::cout << "-I" << INCLUDE_DIR << " "; std::cout << "-I" << INCLUDE_DIR << "/qgis" << std::endl; | int main(int argc, char **argv){ int optionChar; // options structure static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"prefix", no_argument, 0, 'p'}, {"bindir", no_argument, 0, 'b'}, {"includedir", no_argument, 0, 'i'}, {"libdir", no_argument, 0, 'l'}, {0, 0, 0, 0} }; // If no argument is given, show hint if(argc == 1) { std::cout << "qgis_config: argument required" << std::endl; std::cout << "Try \"qgis_config --help\" for more information." << std::endl; }else { // One or more arguments supplied while (1) { /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "pbil", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 'p': std::cout << PREFIX << std::endl; break; case 'b': std::cout << BIN_DIR << std::endl; break; case 'i': std::cout << INCLUDE_DIR << std::endl; break; case 'l': std::cout << LIB_DIR << std::endl; break; case 'h': usage(); return 1; break; default: std::cout << "Try \"qgis_config --help\" for more information." << std::endl; return 1; } } } // return success return 0;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/58aafaf0551c1f10cc113ebd20d1cccab4ad369e/qgis_config.cpp/clean/tools/qgis_config/qgis_config.cpp |
std::cout << LIB_DIR << std::endl; | std::cout << "-L" << LIB_DIR << " "; std::cout << " -lqgis" << std::endl; break; case 'w': std::cout << PLUGIN_DIR << std::endl; | int main(int argc, char **argv){ int optionChar; // options structure static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"prefix", no_argument, 0, 'p'}, {"bindir", no_argument, 0, 'b'}, {"includedir", no_argument, 0, 'i'}, {"libdir", no_argument, 0, 'l'}, {0, 0, 0, 0} }; // If no argument is given, show hint if(argc == 1) { std::cout << "qgis_config: argument required" << std::endl; std::cout << "Try \"qgis_config --help\" for more information." << std::endl; }else { // One or more arguments supplied while (1) { /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "pbil", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 'p': std::cout << PREFIX << std::endl; break; case 'b': std::cout << BIN_DIR << std::endl; break; case 'i': std::cout << INCLUDE_DIR << std::endl; break; case 'l': std::cout << LIB_DIR << std::endl; break; case 'h': usage(); return 1; break; default: std::cout << "Try \"qgis_config --help\" for more information." << std::endl; return 1; } } } // return success return 0;} | 1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/58aafaf0551c1f10cc113ebd20d1cccab4ad369e/qgis_config.cpp/clean/tools/qgis_config/qgis_config.cpp |
Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); | Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); | int main(int argc, char *argv[]){ // FIXME: this can be considered a poor man's solution, as it's not // directly obvious to a gui user. :) // anyway, i vote against removing it even when we have a proper gui // implementation. -- ossi const char *duser = ::getenv("ADMIN_ACCOUNT"); if (duser && duser[0]) options[3].def = duser; KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication::disableAutoDcopRegistration(); KApplication *app = new KApplication; { KStartupInfoId id; id.initId( app->startupId()); id.setupStartupEnv(); // make KDE_STARTUP_ENV env. var. available again } // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); } } else { if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); } command = args->arg(0); for (int i=1; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); bool new_dcop = args->isSet("newdcop"); QCStringList env; QCString options; env << ( "KDE_STARTUP_ENV=" + kapp->startupId()); if (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } if (!new_dcop) { QCString ksycoca = "KDESYCOCA="+QFile::encodeName(locateLocal("tmp", "ksycoca")); env << ksycoca; options += "xf"; // X-only, dcop forwarding enabled. } if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user, options, env) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Check if we need a password SuProcess proc; proc.setUser(auth_user); int needpw = proc.checkNeedPassword(); if (needpw < 0) { QString err = i18n("Su returned with an error!\n"); KMessageBox::error(0L, err); exit(1); } if (needpw == 0) { keep = 0; kdDebug() << "Don't need password!!\n"; } // Start the dialog QCString password; if (needpw) { KStartupInfoId id; id.initId( app->startupId()); KStartupInfoData data; data.setSilent( KStartupInfoData::Yes ); KStartupInfo::sendChange( id, data ); KDEsuDialog dlg(user, auth_user, keep && !terminal); dlg.addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg.addLine(i18n("Priority:"), prio); } int ret = dlg.exec(); if (ret == KDEsuDialog::Rejected) { KStartupInfo::sendFinish( id ); exit(0); } if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg.password(); keep = dlg.keep(); data.setSilent( KStartupInfoData::No ); KStartupInfo::sendChange( id, data ); } // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (keep && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user, options, env); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); if (!new_dcop) { proc.setXOnly(true); proc.setDCOPForwarding(true); } proc.setEnvironment(env); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |
"[email protected]", "http: | "[email protected]", "http: | int main(int argc, char *argv[]){ // FIXME: this can be considered a poor man's solution, as it's not // directly obvious to a gui user. :) // anyway, i vote against removing it even when we have a proper gui // implementation. -- ossi const char *duser = ::getenv("ADMIN_ACCOUNT"); if (duser && duser[0]) options[3].def = duser; KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication::disableAutoDcopRegistration(); KApplication *app = new KApplication; { KStartupInfoId id; id.initId( app->startupId()); id.setupStartupEnv(); // make KDE_STARTUP_ENV env. var. available again } // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); } } else { if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); } command = args->arg(0); for (int i=1; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); bool new_dcop = args->isSet("newdcop"); QCStringList env; QCString options; env << ( "KDE_STARTUP_ENV=" + kapp->startupId()); if (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } if (!new_dcop) { QCString ksycoca = "KDESYCOCA="+QFile::encodeName(locateLocal("tmp", "ksycoca")); env << ksycoca; options += "xf"; // X-only, dcop forwarding enabled. } if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user, options, env) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Check if we need a password SuProcess proc; proc.setUser(auth_user); int needpw = proc.checkNeedPassword(); if (needpw < 0) { QString err = i18n("Su returned with an error!\n"); KMessageBox::error(0L, err); exit(1); } if (needpw == 0) { keep = 0; kdDebug() << "Don't need password!!\n"; } // Start the dialog QCString password; if (needpw) { KStartupInfoId id; id.initId( app->startupId()); KStartupInfoData data; data.setSilent( KStartupInfoData::Yes ); KStartupInfo::sendChange( id, data ); KDEsuDialog dlg(user, auth_user, keep && !terminal); dlg.addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg.addLine(i18n("Priority:"), prio); } int ret = dlg.exec(); if (ret == KDEsuDialog::Rejected) { KStartupInfo::sendFinish( id ); exit(0); } if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg.password(); keep = dlg.keep(); data.setSilent( KStartupInfoData::No ); KStartupInfo::sendChange( id, data ); } // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (keep && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user, options, env); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); if (!new_dcop) { proc.setXOnly(true); proc.setDCOPForwarding(true); } proc.setEnvironment(env); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }} | 3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp |