diff --git a/winsup/cygserver/client.cc b/winsup/cygserver/client.cc index 8a1eeafef..1df23ad9f 100644 --- a/winsup/cygserver/client.cc +++ b/winsup/cygserver/client.cc @@ -1,6 +1,6 @@ /* cygserver_client.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Egor Duda @@ -98,7 +98,7 @@ client_request::send (transport_layer_base *conn) if ((bytes_read = conn->read ((char *)&header, sizeof (header))) != sizeof (header) || (header.cb && - (bytes_read = conn->read (buffer, header.cb) ) != header.cb)) + (bytes_read = conn->read (buffer, header.cb)) != header.cb)) { header.error_code = -1; debug_printf("failed reading response \n"); @@ -180,7 +180,7 @@ cygserver_init () if (cygserver_running==CYGSERVER_OK) return; - client_request_get_version *req = + client_request_get_version *req = new client_request_get_version (); rc = cygserver_request (req); @@ -188,11 +188,11 @@ cygserver_init () if (rc < 0) cygserver_running = CYGSERVER_DEAD; else if (rc > 0) - api_fatal ( "error connecting to cygwin server. error: %d", rc ); + api_fatal ("error connecting to cygwin server. error: %d", rc); else if (req->version.major != CYGWIN_SERVER_VERSION_MAJOR || req->version.api != CYGWIN_SERVER_VERSION_API || req->version.minor > CYGWIN_SERVER_VERSION_MINOR) - api_fatal ( "incompatible version of cygwin server.\n\ + api_fatal ("incompatible version of cygwin server.\n\ client version %d.%d.%d.%d, server version%ld.%ld.%ld.%ld", CYGWIN_SERVER_VERSION_MAJOR, CYGWIN_SERVER_VERSION_API, @@ -201,7 +201,7 @@ cygserver_init () req->version.major, req->version.api, req->version.minor, - req->version.patch ); + req->version.patch); else cygserver_running = CYGSERVER_OK; } diff --git a/winsup/cygserver/cygserver.cc b/winsup/cygserver/cygserver.cc index 57f92c2ac..19f68ea1f 100644 --- a/winsup/cygserver/cygserver.cc +++ b/winsup/cygserver/cygserver.cc @@ -1,6 +1,6 @@ /* cygserver.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Egor Duda @@ -47,26 +47,26 @@ setup_privileges () HANDLE hToken = NULL; TOKEN_PRIVILEGES sPrivileges; - rc = OpenProcessToken ( GetCurrentProcess() , TOKEN_ALL_ACCESS , &hToken ) ; - if ( !rc ) + rc = OpenProcessToken (GetCurrentProcess() , TOKEN_ALL_ACCESS , &hToken) ; + if (!rc) { - printf ( "error opening process token (%lu)\n", GetLastError () ); + printf ("error opening process token (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } - rc = LookupPrivilegeValue ( NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid ); - if ( !rc ) + rc = LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid); + if (!rc) { - printf ( "error getting prigilege luid (%lu)\n", GetLastError () ); + printf ("error getting prigilege luid (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } sPrivileges.PrivilegeCount = 1 ; sPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED ; - rc = AdjustTokenPrivileges ( hToken, FALSE, &sPrivileges, 0, NULL, NULL ) ; - if ( !rc ) + rc = AdjustTokenPrivileges (hToken, FALSE, &sPrivileges, 0, NULL, NULL) ; + if (!rc) { - printf ( "error adjusting prigilege level. (%lu)\n", GetLastError () ); + printf ("error adjusting prigilege level. (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } @@ -79,16 +79,16 @@ setup_privileges () ret_val = TRUE; out: - CloseHandle ( hToken ); + CloseHandle (hToken); return ret_val; } int check_and_dup_handle (HANDLE from_process, HANDLE to_process, HANDLE from_process_token, - DWORD access, - HANDLE from_handle, - HANDLE* to_handle_ptr, BOOL bInheritHandle = FALSE) + DWORD access, + HANDLE from_handle, + HANDLE* to_handle_ptr, BOOL bInheritHandle = FALSE) { HANDLE local_handle = NULL; int ret_val = EACCES; @@ -100,53 +100,53 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process, BOOL status; if (from_process != GetCurrentProcess ()) -{ + { if (!DuplicateHandle (from_process, from_handle, - GetCurrentProcess (), &local_handle, - 0, bInheritHandle, - DUPLICATE_SAME_ACCESS)) + GetCurrentProcess (), &local_handle, + 0, bInheritHandle, + DUPLICATE_SAME_ACCESS)) { - printf ( "error getting handle(%u) to server (%lu)\n", (unsigned int)from_handle, GetLastError ()); + printf ("error getting handle(%u) to server (%lu)\n", (unsigned int)from_handle, GetLastError ()); goto out; } } else local_handle = from_handle; if (!GetKernelObjectSecurity (local_handle, - OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, sd, sizeof (sd_buf), &bytes_needed)) { - printf ( "error getting handle SD (%lu)\n", GetLastError ()); + printf ("error getting handle SD (%lu)\n", GetLastError ()); goto out; } MapGenericMask (&access, &access_mapping); if (!AccessCheck (sd, from_process_token, access, &access_mapping, - &ps, &ps_len, &access, &status)) + &ps, &ps_len, &access, &status)) { - printf ( "error checking access rights (%lu)\n", GetLastError ()); + printf ("error checking access rights (%lu)\n", GetLastError ()); goto out; } if (!status) { - printf ( "access to object denied\n"); + printf ("access to object denied\n"); goto out; } if (!DuplicateHandle (from_process, from_handle, - to_process, to_handle_ptr, - access, bInheritHandle, 0)) + to_process, to_handle_ptr, + access, bInheritHandle, 0)) { - printf ( "error getting handle to client (%lu)\n", GetLastError ()); + printf ("error getting handle to client (%lu)\n", GetLastError ()); goto out; } debug_printf ("Duplicated %p to %p\n", from_handle, *to_handle_ptr); ret_val = 0; - + out: if (local_handle && from_process != GetCurrentProcess ()) CloseHandle (local_handle); @@ -178,7 +178,7 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache } debug_printf ("pid %ld:(%p,%p) -> pid %ld\n", req.master_pid, - req.from_master, req.to_master, + req.from_master, req.to_master, req.pid); debug_printf ("opening process %ld\n", req.master_pid); @@ -194,11 +194,11 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache debug_printf ("Impersonating client\n"); conn->impersonate_client (); - + debug_printf ("about to open thread token\n"); rc = OpenThreadToken (GetCurrentThread (), - TOKEN_QUERY, - TRUE, + TOKEN_QUERY, + TRUE, &token_handle); debug_printf ("opened thread token, rc=%lu\n", rc); @@ -212,10 +212,10 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache } if (check_and_dup_handle (from_process_handle, to_process_handle, - token_handle, - GENERIC_READ, - req.from_master, - &req.from_master, TRUE) != 0) + token_handle, + GENERIC_READ, + req.from_master, + &req.from_master, TRUE) != 0) { printf ("error duplicating from_master handle (%lu)\n", GetLastError ()); header.error_code = EACCES; @@ -238,7 +238,7 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache #if DEBUG printf ("%ld -> %ld(%p,%p)\n", req.master_pid, req.pid, - req.from_master, req.to_master); + req.from_master, req.to_master); #endif header.error_code = 0; @@ -309,7 +309,7 @@ request_loop (LPVOID LpParam) * _AFTER_ the shutdown request. And sending ourselves a request is ugly */ if (new_conn && queue->active) - queue->add (new_conn); + queue->add (new_conn); } return 0; } @@ -382,10 +382,10 @@ server_request::process () bytes_read = conn->read (req->buffer, req->header.cb); if (bytes_read != req->header.cb) - { - debug_printf ("error reading from connection (%lu)\n", GetLastError ()); - goto out; - } + { + debug_printf ("error reading from connection (%lu)\n", GetLastError ()); + goto out; + } debug_printf ("got body (%ld)\n",bytes_read); } @@ -458,10 +458,10 @@ main (int argc, char **argv) switch (i) { case 's': - shutdown = 1; - break; + shutdown = 1; + break; default: - break; + break; /*NOTREACHED*/ } @@ -489,17 +489,17 @@ main (int argc, char **argv) char version[200]; /* Cygwin dll release */ snprintf (version, 200, "%d.%d.%d(%d.%d/%d/%d)-(%d.%d.%d.%d) %s", - cygwin_version.dll_major / 1000, - cygwin_version.dll_major % 1000, - cygwin_version.dll_minor, - cygwin_version.api_major, - cygwin_version.api_minor, - cygwin_version.shared_data, + cygwin_version.dll_major / 1000, + cygwin_version.dll_major % 1000, + cygwin_version.dll_minor, + cygwin_version.api_major, + cygwin_version.api_minor, + cygwin_version.shared_data, CYGWIN_SERVER_VERSION_MAJOR, CYGWIN_SERVER_VERSION_API, CYGWIN_SERVER_VERSION_MINOR, CYGWIN_SERVER_VERSION_PATCH, - cygwin_version.mount_registry, + cygwin_version.mount_registry, cygwin_version.dll_build_date); setbuf (stdout, NULL); printf ("daemon version %s starting up", version); @@ -533,7 +533,7 @@ main (int argc, char **argv) /* WaitForMultipleObjects abort && request_queue && process_queue && signal -- if signal event then retrigger it */ - while (1 && request_queue.active) + while (1 && request_queue.active) { sleep (1); } diff --git a/winsup/cygserver/process.cc b/winsup/cygserver/process.cc index a5173afd3..4d0de2067 100644 --- a/winsup/cygserver/process.cc +++ b/winsup/cygserver/process.cc @@ -1,6 +1,6 @@ /* cygserver_process.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -117,10 +117,10 @@ process_cache::remove_process (class process *theprocess) { entry = (class process *) InterlockedExchangePointer (&head, theprocess->next); if (entry != theprocess) - { - printf ("Bug encountered, process cache corrupted\n"); + { + printf ("Bug encountered, process cache corrupted\n"); exit (1); - } + } } else { @@ -138,10 +138,9 @@ process_cache::remove_process (class process *theprocess) add_task (theprocess); } - /* copy <= max_copy HANDLEs to dest[], starting at an offset into _our list_ of * begin_at. (Ie begin_at = 5, the first copied handle is still written to dest[0] - * NOTE: Thread safe, but not thread guaranteed - a newly added process may be missed. + * NOTE: Thread safe, but not thread guaranteed - a newly added process may be missed. * Who cares - It'll get caught the next time. */ int @@ -227,7 +226,7 @@ process::handle () // thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, winpid); // debug_printf ("Got handle %p when refreshing cache process %ld\n", thehandle, winpid); // /* FIXME: what if OpenProcess fails ? */ -// if (thehandle) +// if (thehandle) // { // _exit_status = STILL_ACTIVE; // exit_code (); @@ -281,7 +280,7 @@ process::add_cleanup_routine (class cleanup_routine *new_cleanup) if (cleaning_up) return false; EnterCriticalSection (&access); - /* check that we didn't block with ::cleanup () + /* check that we didn't block with ::cleanup () * This rigmarole is to get around win9x's glaring missing TryEnterCriticalSection call * which would be a whole lot easier */ diff --git a/winsup/cygserver/shm.cc b/winsup/cygserver/shm.cc index 97f05f9d9..0bc351eb2 100644 --- a/winsup/cygserver/shm.cc +++ b/winsup/cygserver/shm.cc @@ -1,6 +1,6 @@ /* cygserver_shm.cc: Single unix specification IPC interface for Cygwin - Copyright 2001 Red Hat, Inc. + Copyright 2001, 2002 Red Hat, Inc. Originally written by Robert Collins @@ -77,7 +77,7 @@ client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_ } /* FIXME: If building on a 64-bit compiler, the address->int typecast will fail. - * Solution: manually calculate the next id value + * Solution: manually calculate the next id value */ #if 0 @@ -136,7 +136,7 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg) */ /* Test result from openbsd: shm ids are persistent cross process if a handle is left - * open. This could lead to resource starvation: we're not copying that behaviour + * open. This could lead to resource starvation: we're not copying that behaviour * unless we have to. (It will involve acygwin1.dll gloal shared list :[ ). */ /* FIXME: shmid should be a verifyable object @@ -182,9 +182,9 @@ delete_shmnode (shmnode **nodeptr) { shmnode *tempnode = shm_head; while (tempnode && tempnode->next != node) - tempnode = tempnode->next; + tempnode = tempnode->next; if (tempnode) - tempnode->next = node->next; + tempnode->next = node->next; // else log the unexpected ! } @@ -198,7 +198,7 @@ delete_shmnode (shmnode **nodeptr) delete node; nodeptr = NULL; } - + void client_request_shm::serve (transport_layer_base * conn, process_cache * cache) { @@ -207,7 +207,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) parameters.in.sd_buf; // /* create a sd for our open requests based on shmflag & 0x01ff */ // psd = alloc_sd (getuid (), getgid (), cygheap->user.logsrv (), -// parameters.in.shmflg & 0x01ff, psd, &sd_size); +// parameters.in.shmflg & 0x01ff, psd, &sd_size); HANDLE from_process_handle = NULL; HANDLE token_handle = NULL; @@ -216,8 +216,8 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) from_process_handle = cache->process (parameters.in.pid)->handle (); /* possible TODO: reduce the access on the handle before we use it */ /* Note that unless we do this, we don't need to call CloseHandle - it's kept open - * by the process cache until the process terminates. - * We may need a refcount on the cache however... + * by the process cache until the process terminates. + * We may need a refcount on the cache however... */ if (!from_process_handle) { @@ -243,7 +243,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* we trust the clients request - we will be doing it as them, and - * the worst they can do is open their own permissions + * the worst they can do is open their own permissions */ @@ -364,9 +364,9 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) delete_shmnode (&temp2); } - header.error_code = 0; - CloseHandle (token_handle); - return; + header.error_code = 0; + CloseHandle (token_handle); + return; } tempnode = &(*tempnode)->next; } @@ -409,7 +409,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* attempt to open the key */ /* get an existing key */ - /* On unix the same shmid identifier is returned on multiple calls to shm_get + /* On unix the same shmid identifier is returned on multiple calls to shm_get * with the same key and size. Different modes is a ?. */ @@ -433,7 +433,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) CloseHandle (token_handle); return; } - /* FIXME: can the same process call this twice without error ? test + /* FIXME: can the same process call this twice without error ? test * on unix */ if ((parameters.in.shmflg & IPC_CREAT) @@ -447,12 +447,12 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) CloseHandle (token_handle); return; } - // FIXME: do we need to other tests of the requested mode with the + // FIXME: do we need to other tests of the requested mode with the // tempnode->shm_id mode ? testcase on unix needed. // FIXME how do we do the security test? or // do we wait for shmat to bother with that? /* One possibly solution: impersonate the client, and then test we can - * reopen the area. In fact we'll probably have to do that to get + * reopen the area. In fact we'll probably have to do that to get * handles back to them, alternatively just tell them the id, and then * let them attempt the open. */ @@ -495,7 +495,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* This may need sh_none... it's only a control structure */ HANDLE filemap = CreateFileMapping (INVALID_HANDLE_VALUE, // system pagefile. &sa, - PAGE_READWRITE, // protection + PAGE_READWRITE, // protection 0x00000000, getsystemallocgranularity (), shmname // object name @@ -621,9 +621,9 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) tempnode->next = shm_head; shm_head = tempnode; - /* we now have the area in the daemon list, opened. + /* we now have the area in the daemon list, opened. - FIXME: leave the system wide shm mutex */ + FIXME: leave the system wide shm mutex */ parameters.out.shm_id = tempnode->shm_id; if (check_and_dup_handle (GetCurrentProcess (), from_process_handle, diff --git a/winsup/cygserver/shm.h b/winsup/cygserver/shm.h index 254ff2fb7..f1dcaa53f 100755 --- a/winsup/cygserver/shm.h +++ b/winsup/cygserver/shm.h @@ -1,6 +1,6 @@ /* cygserver_shm.h - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins This file is part of Cygwin. diff --git a/winsup/cygserver/transport.cc b/winsup/cygserver/transport.cc index 7c6e5fe00..2d81590db 100644 --- a/winsup/cygserver/transport.cc +++ b/winsup/cygserver/transport.cc @@ -1,6 +1,6 @@ /* cygserver_transport.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins diff --git a/winsup/cygserver/transport_pipes.cc b/winsup/cygserver/transport_pipes.cc index 7a43d8da0..f2221700f 100644 --- a/winsup/cygserver/transport_pipes.cc +++ b/winsup/cygserver/transport_pipes.cc @@ -1,6 +1,6 @@ /* cygserver_transport_pipes.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -41,7 +41,7 @@ transport_layer_pipes::transport_layer_pipes (HANDLE new_pipe) init_security(); }; -transport_layer_pipes::transport_layer_pipes () +transport_layer_pipes::transport_layer_pipes () { inited = false; pipe = NULL; @@ -80,11 +80,11 @@ transport_layer_pipes::accept () } pipe = CreateNamedPipe (pipe_name, - PIPE_ACCESS_DUPLEX, - PIPE_TYPE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, - 0, 0, 1000, - &sec_all_nih ); + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + 0, 0, 1000, + &sec_all_nih ); if (pipe == INVALID_HANDLE_VALUE) { debug_printf ("error creating pipe (%lu)\n.", GetLastError ()); @@ -99,11 +99,11 @@ transport_layer_pipes::accept () pipe = NULL; return NULL; } - + transport_layer_pipes *new_conn = new transport_layer_pipes (pipe); pipe = NULL; - return new_conn; + return new_conn; } void @@ -164,27 +164,27 @@ transport_layer_pipes::connect () while (1) { pipe = CreateFile (pipe_name, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sec_all_nih, - OPEN_EXISTING, - 0, NULL); + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + &sec_all_nih, + OPEN_EXISTING, + 0, NULL); if (pipe != INVALID_HANDLE_VALUE) /* got the pipe */ - return true; + return true; if (GetLastError () != ERROR_PIPE_BUSY) - { - debug_printf ("Error opening the pipe (%lu)\n", GetLastError ()); - pipe = NULL; - return false; - } + { + debug_printf ("Error opening the pipe (%lu)\n", GetLastError ()); + pipe = NULL; + return false; + } if (!WaitNamedPipe (pipe_name, 20000)) - debug_printf ( "error connecting to server pipe after 20 seconds (%lu)\n", GetLastError () ); + debug_printf ( "error connecting to server pipe after 20 seconds (%lu)\n", GetLastError () ); /* We loop here, because the pipe exists but is busy. If it doesn't exist * the != ERROR_PIPE_BUSY will catch it. - */ + */ } } @@ -204,7 +204,7 @@ transport_layer_pipes::impersonate_client () void transport_layer_pipes::revert_to_self () { - RevertToSelf (); + RevertToSelf (); debug_printf("I am who I yam\n"); } diff --git a/winsup/cygserver/transport_sockets.cc b/winsup/cygserver/transport_sockets.cc index 6b75365b4..a3a98b3e5 100644 --- a/winsup/cygserver/transport_sockets.cc +++ b/winsup/cygserver/transport_sockets.cc @@ -1,6 +1,6 @@ /* cygserver_transport_sockets.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -28,7 +28,7 @@ extern "C" int cygwin_socket (int af, int type, int protocol); extern "C" int cygwin_connect (int fd, - const struct sockaddr *name, + const struct sockaddr *name, int namelen); extern "C" int cygwin_accept (int fd, struct sockaddr *peer, int *len); @@ -86,10 +86,10 @@ transport_layer_sockets::accept () printf ("Nup, could' accept. %d\n",errno); return NULL; } - + transport_layer_sockets *new_conn = new transport_layer_sockets (new_fd); - return new_conn; + return new_conn; } diff --git a/winsup/cygwin/cygserver.cc b/winsup/cygwin/cygserver.cc index 57f92c2ac..19f68ea1f 100755 --- a/winsup/cygwin/cygserver.cc +++ b/winsup/cygwin/cygserver.cc @@ -1,6 +1,6 @@ /* cygserver.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Egor Duda @@ -47,26 +47,26 @@ setup_privileges () HANDLE hToken = NULL; TOKEN_PRIVILEGES sPrivileges; - rc = OpenProcessToken ( GetCurrentProcess() , TOKEN_ALL_ACCESS , &hToken ) ; - if ( !rc ) + rc = OpenProcessToken (GetCurrentProcess() , TOKEN_ALL_ACCESS , &hToken) ; + if (!rc) { - printf ( "error opening process token (%lu)\n", GetLastError () ); + printf ("error opening process token (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } - rc = LookupPrivilegeValue ( NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid ); - if ( !rc ) + rc = LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &sPrivileges.Privileges[0].Luid); + if (!rc) { - printf ( "error getting prigilege luid (%lu)\n", GetLastError () ); + printf ("error getting prigilege luid (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } sPrivileges.PrivilegeCount = 1 ; sPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED ; - rc = AdjustTokenPrivileges ( hToken, FALSE, &sPrivileges, 0, NULL, NULL ) ; - if ( !rc ) + rc = AdjustTokenPrivileges (hToken, FALSE, &sPrivileges, 0, NULL, NULL) ; + if (!rc) { - printf ( "error adjusting prigilege level. (%lu)\n", GetLastError () ); + printf ("error adjusting prigilege level. (%lu)\n", GetLastError ()); ret_val = FALSE; goto out; } @@ -79,16 +79,16 @@ setup_privileges () ret_val = TRUE; out: - CloseHandle ( hToken ); + CloseHandle (hToken); return ret_val; } int check_and_dup_handle (HANDLE from_process, HANDLE to_process, HANDLE from_process_token, - DWORD access, - HANDLE from_handle, - HANDLE* to_handle_ptr, BOOL bInheritHandle = FALSE) + DWORD access, + HANDLE from_handle, + HANDLE* to_handle_ptr, BOOL bInheritHandle = FALSE) { HANDLE local_handle = NULL; int ret_val = EACCES; @@ -100,53 +100,53 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process, BOOL status; if (from_process != GetCurrentProcess ()) -{ + { if (!DuplicateHandle (from_process, from_handle, - GetCurrentProcess (), &local_handle, - 0, bInheritHandle, - DUPLICATE_SAME_ACCESS)) + GetCurrentProcess (), &local_handle, + 0, bInheritHandle, + DUPLICATE_SAME_ACCESS)) { - printf ( "error getting handle(%u) to server (%lu)\n", (unsigned int)from_handle, GetLastError ()); + printf ("error getting handle(%u) to server (%lu)\n", (unsigned int)from_handle, GetLastError ()); goto out; } } else local_handle = from_handle; if (!GetKernelObjectSecurity (local_handle, - OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, sd, sizeof (sd_buf), &bytes_needed)) { - printf ( "error getting handle SD (%lu)\n", GetLastError ()); + printf ("error getting handle SD (%lu)\n", GetLastError ()); goto out; } MapGenericMask (&access, &access_mapping); if (!AccessCheck (sd, from_process_token, access, &access_mapping, - &ps, &ps_len, &access, &status)) + &ps, &ps_len, &access, &status)) { - printf ( "error checking access rights (%lu)\n", GetLastError ()); + printf ("error checking access rights (%lu)\n", GetLastError ()); goto out; } if (!status) { - printf ( "access to object denied\n"); + printf ("access to object denied\n"); goto out; } if (!DuplicateHandle (from_process, from_handle, - to_process, to_handle_ptr, - access, bInheritHandle, 0)) + to_process, to_handle_ptr, + access, bInheritHandle, 0)) { - printf ( "error getting handle to client (%lu)\n", GetLastError ()); + printf ("error getting handle to client (%lu)\n", GetLastError ()); goto out; } debug_printf ("Duplicated %p to %p\n", from_handle, *to_handle_ptr); ret_val = 0; - + out: if (local_handle && from_process != GetCurrentProcess ()) CloseHandle (local_handle); @@ -178,7 +178,7 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache } debug_printf ("pid %ld:(%p,%p) -> pid %ld\n", req.master_pid, - req.from_master, req.to_master, + req.from_master, req.to_master, req.pid); debug_printf ("opening process %ld\n", req.master_pid); @@ -194,11 +194,11 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache debug_printf ("Impersonating client\n"); conn->impersonate_client (); - + debug_printf ("about to open thread token\n"); rc = OpenThreadToken (GetCurrentThread (), - TOKEN_QUERY, - TRUE, + TOKEN_QUERY, + TRUE, &token_handle); debug_printf ("opened thread token, rc=%lu\n", rc); @@ -212,10 +212,10 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache } if (check_and_dup_handle (from_process_handle, to_process_handle, - token_handle, - GENERIC_READ, - req.from_master, - &req.from_master, TRUE) != 0) + token_handle, + GENERIC_READ, + req.from_master, + &req.from_master, TRUE) != 0) { printf ("error duplicating from_master handle (%lu)\n", GetLastError ()); header.error_code = EACCES; @@ -238,7 +238,7 @@ client_request_attach_tty::serve(transport_layer_base *conn, class process_cache #if DEBUG printf ("%ld -> %ld(%p,%p)\n", req.master_pid, req.pid, - req.from_master, req.to_master); + req.from_master, req.to_master); #endif header.error_code = 0; @@ -309,7 +309,7 @@ request_loop (LPVOID LpParam) * _AFTER_ the shutdown request. And sending ourselves a request is ugly */ if (new_conn && queue->active) - queue->add (new_conn); + queue->add (new_conn); } return 0; } @@ -382,10 +382,10 @@ server_request::process () bytes_read = conn->read (req->buffer, req->header.cb); if (bytes_read != req->header.cb) - { - debug_printf ("error reading from connection (%lu)\n", GetLastError ()); - goto out; - } + { + debug_printf ("error reading from connection (%lu)\n", GetLastError ()); + goto out; + } debug_printf ("got body (%ld)\n",bytes_read); } @@ -458,10 +458,10 @@ main (int argc, char **argv) switch (i) { case 's': - shutdown = 1; - break; + shutdown = 1; + break; default: - break; + break; /*NOTREACHED*/ } @@ -489,17 +489,17 @@ main (int argc, char **argv) char version[200]; /* Cygwin dll release */ snprintf (version, 200, "%d.%d.%d(%d.%d/%d/%d)-(%d.%d.%d.%d) %s", - cygwin_version.dll_major / 1000, - cygwin_version.dll_major % 1000, - cygwin_version.dll_minor, - cygwin_version.api_major, - cygwin_version.api_minor, - cygwin_version.shared_data, + cygwin_version.dll_major / 1000, + cygwin_version.dll_major % 1000, + cygwin_version.dll_minor, + cygwin_version.api_major, + cygwin_version.api_minor, + cygwin_version.shared_data, CYGWIN_SERVER_VERSION_MAJOR, CYGWIN_SERVER_VERSION_API, CYGWIN_SERVER_VERSION_MINOR, CYGWIN_SERVER_VERSION_PATCH, - cygwin_version.mount_registry, + cygwin_version.mount_registry, cygwin_version.dll_build_date); setbuf (stdout, NULL); printf ("daemon version %s starting up", version); @@ -533,7 +533,7 @@ main (int argc, char **argv) /* WaitForMultipleObjects abort && request_queue && process_queue && signal -- if signal event then retrigger it */ - while (1 && request_queue.active) + while (1 && request_queue.active) { sleep (1); } diff --git a/winsup/cygwin/cygserver_client.cc b/winsup/cygwin/cygserver_client.cc index 8a1eeafef..1df23ad9f 100755 --- a/winsup/cygwin/cygserver_client.cc +++ b/winsup/cygwin/cygserver_client.cc @@ -1,6 +1,6 @@ /* cygserver_client.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Egor Duda @@ -98,7 +98,7 @@ client_request::send (transport_layer_base *conn) if ((bytes_read = conn->read ((char *)&header, sizeof (header))) != sizeof (header) || (header.cb && - (bytes_read = conn->read (buffer, header.cb) ) != header.cb)) + (bytes_read = conn->read (buffer, header.cb)) != header.cb)) { header.error_code = -1; debug_printf("failed reading response \n"); @@ -180,7 +180,7 @@ cygserver_init () if (cygserver_running==CYGSERVER_OK) return; - client_request_get_version *req = + client_request_get_version *req = new client_request_get_version (); rc = cygserver_request (req); @@ -188,11 +188,11 @@ cygserver_init () if (rc < 0) cygserver_running = CYGSERVER_DEAD; else if (rc > 0) - api_fatal ( "error connecting to cygwin server. error: %d", rc ); + api_fatal ("error connecting to cygwin server. error: %d", rc); else if (req->version.major != CYGWIN_SERVER_VERSION_MAJOR || req->version.api != CYGWIN_SERVER_VERSION_API || req->version.minor > CYGWIN_SERVER_VERSION_MINOR) - api_fatal ( "incompatible version of cygwin server.\n\ + api_fatal ("incompatible version of cygwin server.\n\ client version %d.%d.%d.%d, server version%ld.%ld.%ld.%ld", CYGWIN_SERVER_VERSION_MAJOR, CYGWIN_SERVER_VERSION_API, @@ -201,7 +201,7 @@ cygserver_init () req->version.major, req->version.api, req->version.minor, - req->version.patch ); + req->version.patch); else cygserver_running = CYGSERVER_OK; } diff --git a/winsup/cygwin/cygserver_process.cc b/winsup/cygwin/cygserver_process.cc index a5173afd3..4d0de2067 100755 --- a/winsup/cygwin/cygserver_process.cc +++ b/winsup/cygwin/cygserver_process.cc @@ -1,6 +1,6 @@ /* cygserver_process.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -117,10 +117,10 @@ process_cache::remove_process (class process *theprocess) { entry = (class process *) InterlockedExchangePointer (&head, theprocess->next); if (entry != theprocess) - { - printf ("Bug encountered, process cache corrupted\n"); + { + printf ("Bug encountered, process cache corrupted\n"); exit (1); - } + } } else { @@ -138,10 +138,9 @@ process_cache::remove_process (class process *theprocess) add_task (theprocess); } - /* copy <= max_copy HANDLEs to dest[], starting at an offset into _our list_ of * begin_at. (Ie begin_at = 5, the first copied handle is still written to dest[0] - * NOTE: Thread safe, but not thread guaranteed - a newly added process may be missed. + * NOTE: Thread safe, but not thread guaranteed - a newly added process may be missed. * Who cares - It'll get caught the next time. */ int @@ -227,7 +226,7 @@ process::handle () // thehandle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, winpid); // debug_printf ("Got handle %p when refreshing cache process %ld\n", thehandle, winpid); // /* FIXME: what if OpenProcess fails ? */ -// if (thehandle) +// if (thehandle) // { // _exit_status = STILL_ACTIVE; // exit_code (); @@ -281,7 +280,7 @@ process::add_cleanup_routine (class cleanup_routine *new_cleanup) if (cleaning_up) return false; EnterCriticalSection (&access); - /* check that we didn't block with ::cleanup () + /* check that we didn't block with ::cleanup () * This rigmarole is to get around win9x's glaring missing TryEnterCriticalSection call * which would be a whole lot easier */ diff --git a/winsup/cygwin/cygserver_shm.cc b/winsup/cygwin/cygserver_shm.cc index 97f05f9d9..0bc351eb2 100755 --- a/winsup/cygwin/cygserver_shm.cc +++ b/winsup/cygwin/cygserver_shm.cc @@ -1,6 +1,6 @@ /* cygserver_shm.cc: Single unix specification IPC interface for Cygwin - Copyright 2001 Red Hat, Inc. + Copyright 2001, 2002 Red Hat, Inc. Originally written by Robert Collins @@ -77,7 +77,7 @@ client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_ } /* FIXME: If building on a 64-bit compiler, the address->int typecast will fail. - * Solution: manually calculate the next id value + * Solution: manually calculate the next id value */ #if 0 @@ -136,7 +136,7 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg) */ /* Test result from openbsd: shm ids are persistent cross process if a handle is left - * open. This could lead to resource starvation: we're not copying that behaviour + * open. This could lead to resource starvation: we're not copying that behaviour * unless we have to. (It will involve acygwin1.dll gloal shared list :[ ). */ /* FIXME: shmid should be a verifyable object @@ -182,9 +182,9 @@ delete_shmnode (shmnode **nodeptr) { shmnode *tempnode = shm_head; while (tempnode && tempnode->next != node) - tempnode = tempnode->next; + tempnode = tempnode->next; if (tempnode) - tempnode->next = node->next; + tempnode->next = node->next; // else log the unexpected ! } @@ -198,7 +198,7 @@ delete_shmnode (shmnode **nodeptr) delete node; nodeptr = NULL; } - + void client_request_shm::serve (transport_layer_base * conn, process_cache * cache) { @@ -207,7 +207,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) PSECURITY_DESCRIPTOR psd = (PSECURITY_DESCRIPTOR) parameters.in.sd_buf; // /* create a sd for our open requests based on shmflag & 0x01ff */ // psd = alloc_sd (getuid (), getgid (), cygheap->user.logsrv (), -// parameters.in.shmflg & 0x01ff, psd, &sd_size); +// parameters.in.shmflg & 0x01ff, psd, &sd_size); HANDLE from_process_handle = NULL; HANDLE token_handle = NULL; @@ -216,8 +216,8 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) from_process_handle = cache->process (parameters.in.pid)->handle (); /* possible TODO: reduce the access on the handle before we use it */ /* Note that unless we do this, we don't need to call CloseHandle - it's kept open - * by the process cache until the process terminates. - * We may need a refcount on the cache however... + * by the process cache until the process terminates. + * We may need a refcount on the cache however... */ if (!from_process_handle) { @@ -243,7 +243,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* we trust the clients request - we will be doing it as them, and - * the worst they can do is open their own permissions + * the worst they can do is open their own permissions */ @@ -364,9 +364,9 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) delete_shmnode (&temp2); } - header.error_code = 0; - CloseHandle (token_handle); - return; + header.error_code = 0; + CloseHandle (token_handle); + return; } tempnode = &(*tempnode)->next; } @@ -409,7 +409,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* attempt to open the key */ /* get an existing key */ - /* On unix the same shmid identifier is returned on multiple calls to shm_get + /* On unix the same shmid identifier is returned on multiple calls to shm_get * with the same key and size. Different modes is a ?. */ @@ -433,7 +433,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) CloseHandle (token_handle); return; } - /* FIXME: can the same process call this twice without error ? test + /* FIXME: can the same process call this twice without error ? test * on unix */ if ((parameters.in.shmflg & IPC_CREAT) @@ -447,12 +447,12 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) CloseHandle (token_handle); return; } - // FIXME: do we need to other tests of the requested mode with the + // FIXME: do we need to other tests of the requested mode with the // tempnode->shm_id mode ? testcase on unix needed. // FIXME how do we do the security test? or // do we wait for shmat to bother with that? /* One possibly solution: impersonate the client, and then test we can - * reopen the area. In fact we'll probably have to do that to get + * reopen the area. In fact we'll probably have to do that to get * handles back to them, alternatively just tell them the id, and then * let them attempt the open. */ @@ -495,7 +495,7 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) /* This may need sh_none... it's only a control structure */ HANDLE filemap = CreateFileMapping (INVALID_HANDLE_VALUE, // system pagefile. &sa, - PAGE_READWRITE, // protection + PAGE_READWRITE, // protection 0x00000000, getsystemallocgranularity (), shmname // object name @@ -621,9 +621,9 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache) tempnode->next = shm_head; shm_head = tempnode; - /* we now have the area in the daemon list, opened. + /* we now have the area in the daemon list, opened. - FIXME: leave the system wide shm mutex */ + FIXME: leave the system wide shm mutex */ parameters.out.shm_id = tempnode->shm_id; if (check_and_dup_handle (GetCurrentProcess (), from_process_handle, diff --git a/winsup/cygwin/cygserver_shm.h b/winsup/cygwin/cygserver_shm.h index 254ff2fb7..f1dcaa53f 100644 --- a/winsup/cygwin/cygserver_shm.h +++ b/winsup/cygwin/cygserver_shm.h @@ -1,6 +1,6 @@ /* cygserver_shm.h - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins This file is part of Cygwin. diff --git a/winsup/cygwin/cygserver_transport.cc b/winsup/cygwin/cygserver_transport.cc index 7c6e5fe00..2d81590db 100755 --- a/winsup/cygwin/cygserver_transport.cc +++ b/winsup/cygwin/cygserver_transport.cc @@ -1,6 +1,6 @@ /* cygserver_transport.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins diff --git a/winsup/cygwin/cygserver_transport_pipes.cc b/winsup/cygwin/cygserver_transport_pipes.cc index 7a43d8da0..f2221700f 100755 --- a/winsup/cygwin/cygserver_transport_pipes.cc +++ b/winsup/cygwin/cygserver_transport_pipes.cc @@ -1,6 +1,6 @@ /* cygserver_transport_pipes.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -41,7 +41,7 @@ transport_layer_pipes::transport_layer_pipes (HANDLE new_pipe) init_security(); }; -transport_layer_pipes::transport_layer_pipes () +transport_layer_pipes::transport_layer_pipes () { inited = false; pipe = NULL; @@ -80,11 +80,11 @@ transport_layer_pipes::accept () } pipe = CreateNamedPipe (pipe_name, - PIPE_ACCESS_DUPLEX, - PIPE_TYPE_BYTE | PIPE_WAIT, - PIPE_UNLIMITED_INSTANCES, - 0, 0, 1000, - &sec_all_nih ); + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_BYTE | PIPE_WAIT, + PIPE_UNLIMITED_INSTANCES, + 0, 0, 1000, + &sec_all_nih ); if (pipe == INVALID_HANDLE_VALUE) { debug_printf ("error creating pipe (%lu)\n.", GetLastError ()); @@ -99,11 +99,11 @@ transport_layer_pipes::accept () pipe = NULL; return NULL; } - + transport_layer_pipes *new_conn = new transport_layer_pipes (pipe); pipe = NULL; - return new_conn; + return new_conn; } void @@ -164,27 +164,27 @@ transport_layer_pipes::connect () while (1) { pipe = CreateFile (pipe_name, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - &sec_all_nih, - OPEN_EXISTING, - 0, NULL); + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + &sec_all_nih, + OPEN_EXISTING, + 0, NULL); if (pipe != INVALID_HANDLE_VALUE) /* got the pipe */ - return true; + return true; if (GetLastError () != ERROR_PIPE_BUSY) - { - debug_printf ("Error opening the pipe (%lu)\n", GetLastError ()); - pipe = NULL; - return false; - } + { + debug_printf ("Error opening the pipe (%lu)\n", GetLastError ()); + pipe = NULL; + return false; + } if (!WaitNamedPipe (pipe_name, 20000)) - debug_printf ( "error connecting to server pipe after 20 seconds (%lu)\n", GetLastError () ); + debug_printf ( "error connecting to server pipe after 20 seconds (%lu)\n", GetLastError () ); /* We loop here, because the pipe exists but is busy. If it doesn't exist * the != ERROR_PIPE_BUSY will catch it. - */ + */ } } @@ -204,7 +204,7 @@ transport_layer_pipes::impersonate_client () void transport_layer_pipes::revert_to_self () { - RevertToSelf (); + RevertToSelf (); debug_printf("I am who I yam\n"); } diff --git a/winsup/cygwin/cygserver_transport_sockets.cc b/winsup/cygwin/cygserver_transport_sockets.cc index 6b75365b4..a3a98b3e5 100755 --- a/winsup/cygwin/cygserver_transport_sockets.cc +++ b/winsup/cygwin/cygserver_transport_sockets.cc @@ -1,6 +1,6 @@ /* cygserver_transport_sockets.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins @@ -28,7 +28,7 @@ extern "C" int cygwin_socket (int af, int type, int protocol); extern "C" int cygwin_connect (int fd, - const struct sockaddr *name, + const struct sockaddr *name, int namelen); extern "C" int cygwin_accept (int fd, struct sockaddr *peer, int *len); @@ -86,10 +86,10 @@ transport_layer_sockets::accept () printf ("Nup, could' accept. %d\n",errno); return NULL; } - + transport_layer_sockets *new_conn = new transport_layer_sockets (new_fd); - return new_conn; + return new_conn; } diff --git a/winsup/cygwin/include/cygwin/cygserver.h b/winsup/cygwin/include/cygwin/cygserver.h index 3751863f5..c7a04929f 100755 --- a/winsup/cygwin/include/cygwin/cygserver.h +++ b/winsup/cygwin/include/cygwin/cygserver.h @@ -1,6 +1,6 @@ /* cygserver.h - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Egor Duda diff --git a/winsup/cygwin/include/cygwin/cygserver_process.h b/winsup/cygwin/include/cygwin/cygserver_process.h index 4a49212b2..c8ff40b09 100755 --- a/winsup/cygwin/include/cygwin/cygserver_process.h +++ b/winsup/cygwin/include/cygwin/cygserver_process.h @@ -1,6 +1,6 @@ /* cygserver_process.h - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins diff --git a/winsup/cygwin/include/cygwin/cygserver_transport.h b/winsup/cygwin/include/cygwin/cygserver_transport.h index 1ed16edf7..493c9b530 100755 --- a/winsup/cygwin/include/cygwin/cygserver_transport.h +++ b/winsup/cygwin/include/cygwin/cygserver_transport.h @@ -1,6 +1,6 @@ /* cygserver.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins diff --git a/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h b/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h index 9afeebfef..9ebeee2a4 100755 --- a/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h +++ b/winsup/cygwin/include/cygwin/cygserver_transport_pipes.h @@ -1,6 +1,6 @@ /* cygserver.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins diff --git a/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h b/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h index 94dc43e38..9881ca2bb 100755 --- a/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h +++ b/winsup/cygwin/include/cygwin/cygserver_transport_sockets.h @@ -1,6 +1,6 @@ /* cygserver.cc - Copyright 2001 Red Hat Inc. + Copyright 2001, 2002 Red Hat Inc. Written by Robert Collins