+2008-11-26 Christopher Faylor <me+cygwin@cgf.cx>
+
+ Remove unneeded whitespace.
+
+ * fhandler_fifo.cc (fhandler_fifo::open): Rework to cause errno to be
+ set to ENXIO when opening a fifo write/nonblocking.
+
+ * environ.cc (ucreqenv): Rename to ucenv. Move code from old ucenv
+ here and conditionalize it on create_upcaseenv.
+ (ucenv): Delete.
+ (environ_init): Fix compiler warning by moving create_upcaseenv test to
+ ucenv. Don't bother checking for child_proc_info when calling ucenv
+ since it is assumed to be NULL at the point where the function is
+ called.
+
+ * path.cc (symlink_worker): Turn off MS-DOS path warnings when dealing
+ with devices since the device handler passes in a translated MS-DOS
+ path.
+
+ * sec_auth.cc (lsaprivkeyauth): Avoid variable initialization which
+ causes a compiler error.
+
+ * fhandler_netdrive.cc: Update copyright.
+
2008-11-26 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Add setlsapwd.o.
return 0;
}
-/* Turn environment variable part of a=b string into uppercase. */
-static __inline__ void
-ucenv (char *p, char *eq)
-{
- /* Amazingly, NT has a case sensitive environment name list,
- but only sometimes.
- It's normal to have NT set your "Path" to something.
- Later, you set "PATH" to something else. This alters "Path".
- But if you try and do a naive getenv on "PATH" you'll get nothing.
-
- So we upper case the labels here to prevent confusion later but
- we only do it for the first process in a session group. */
- for (; p < eq; p++)
- if (islower (*p))
- *p = cyg_toupper (*p);
-}
-
/* Minimal list of Windows vars which must be converted to uppercase.
Either for POSIX compatibility of for backward compatibility with
existing applications. */
static struct renv {
- const char *name;
- const size_t namelen;
+ const char *name;
+ const size_t namelen;
} renv_arr[] = {
- { NL("ALLUSERSPROFILE=") }, // 0
- { NL("COMMONPROGRAMFILES=") }, // 1
- { NL("COMPUTERNAME=") },
- { NL("COMSPEC=") },
- { NL("HOME=") }, // 4
- { NL("HOMEDRIVE=") },
- { NL("HOMEPATH=") },
- { NL("NUMBER_OF_PROCESSORS=") }, // 7
- { NL("OS=") }, // 8
- { NL("PATH=") }, // 9
- { NL("PATHEXT=") },
- { NL("PROCESSOR_ARCHITECTURE=") },
- { NL("PROCESSOR_IDENTIFIER=") },
- { NL("PROCESSOR_LEVEL=") },
- { NL("PROCESSOR_REVISION=") },
- { NL("PROGRAMFILES=") },
- { NL("SYSTEMDRIVE=") }, // 16
- { NL("SYSTEMROOT=") },
- { NL("TEMP=") }, // 18
- { NL("TERM=") },
- { NL("TMP=") },
- { NL("TMPDIR=") },
- { NL("WINDIR=") } // 22
+ { NL("ALLUSERSPROFILE=") }, // 0
+ { NL("COMMONPROGRAMFILES=") }, // 1
+ { NL("COMPUTERNAME=") },
+ { NL("COMSPEC=") },
+ { NL("HOME=") }, // 4
+ { NL("HOMEDRIVE=") },
+ { NL("HOMEPATH=") },
+ { NL("NUMBER_OF_PROCESSORS=") }, // 7
+ { NL("OS=") }, // 8
+ { NL("PATH=") }, // 9
+ { NL("PATHEXT=") },
+ { NL("PROCESSOR_ARCHITECTURE=") },
+ { NL("PROCESSOR_IDENTIFIER=") },
+ { NL("PROCESSOR_LEVEL=") },
+ { NL("PROCESSOR_REVISION=") },
+ { NL("PROGRAMFILES=") },
+ { NL("SYSTEMDRIVE=") }, // 16
+ { NL("SYSTEMROOT=") },
+ { NL("TEMP=") }, // 18
+ { NL("TERM=") },
+ { NL("TMP=") },
+ { NL("TMPDIR=") },
+ { NL("WINDIR=") } // 22
};
#define RENV_SIZE (sizeof (renv_arr) / sizeof (renv_arr[0]))
/* Set of first characters of the above list of variables. */
starts. */
static const int start_at[] = { 0, 1, 4, 7, 8, 9, 16, 18, 22 };
-/* Hopefully as quick as possible. Only upcase specific set of important
- Windows variables. */
+/* Turn environment variable part of a=b string into uppercase.
+ Conditionally controlled by upcaseenv CYGWIN setting. */
static __inline__ void
-ucreqenv (char *p)
+ucenv (char *p, const char *eq)
{
- char first = cyg_toupper (*p);
- const char *idx = strchr (idx_arr, first);
- if (idx)
- for (size_t i = start_at[idx - idx_arr];
- i < RENV_SIZE && renv_arr[i].name[0] == first;
- ++i)
- if (strncasematch (p, renv_arr[i].name, renv_arr[i].namelen))
- {
- strncpy (p, renv_arr[i].name, renv_arr[i].namelen);
- break;
- }
+ if (create_upcaseenv)
+ {
+ /* Amazingly, NT has a case sensitive environment name list,
+ but only sometimes.
+ It's normal to have NT set your "Path" to something.
+ Later, you set "PATH" to something else. This alters "Path".
+ But if you try and do a naive getenv on "PATH" you'll get nothing.
+
+ So we upper case the labels here to prevent confusion later but
+ we only do it for processes that are started by non-Cygwin programs. */
+ for (; p < eq; p++)
+ if (islower (*p))
+ *p = cyg_toupper (*p);
+ }
+ else
+ {
+ /* Hopefully as quickly as possible - only upcase specific set of important
+ Windows variables. */
+ char first = cyg_toupper (*p);
+ const char *idx = strchr (idx_arr, first);
+ if (idx)
+ for (size_t i = start_at[idx - idx_arr];
+ i < RENV_SIZE && renv_arr[i].name[0] == first;
+ ++i)
+ if (strncasematch (p, renv_arr[i].name, renv_arr[i].namelen))
+ {
+ strncpy (p, renv_arr[i].name, renv_arr[i].namelen);
+ break;
+ }
+ }
}
/* Parse CYGWIN options */
if (*newp == '=')
*newp = '!';
char *eq = strechr (newp, '=');
- if (!child_proc_info)
- if (create_upcaseenv)
- ucenv (newp, eq); /* Uppercase all env vars. */
- else
- ucreqenv (newp); /* Uppercase only selected vars. */
+ ucenv (newp, eq); /* (possibly conditionally) uppercase env vars. */
if (*newp == 'T' && strncmp (newp, "TERM=", 5) == 0)
sawTERM = 1;
- if (*eq && conv_start_chars[(unsigned char)envp[i][0]])
+ if (*eq && conv_start_chars[(unsigned char) envp[i][0]])
posify (envp + i, *++eq ? eq : --eq, tmpbuf);
debug_printf ("%p: %s", envp[i], envp[i]);
}
case F_SETLK:
case F_SETLKW:
{
- struct __flock64 *fl = (struct __flock64 *) arg;
- fl->l_type &= F_RDLCK | F_WRLCK | F_UNLCK;
- res = cfd->lock (cmd, fl);
+ struct __flock64 *fl = (struct __flock64 *) arg;
+ fl->l_type &= F_RDLCK | F_WRLCK | F_UNLCK;
+ res = cfd->lock (cmd, fl);
}
break;
default:
if (query_open () && pc.fs_is_nfs ())
{
/* Make sure we can read EAs of files on an NFS share. Also make
- sure that we're going to act on the file itself, even if it'a
+ sure that we're going to act on the file itself, even if it'a
a symlink. */
access |= FILE_READ_EA;
if (query_open () >= query_write_control)
- access |= FILE_WRITE_EA;
+ access |= FILE_WRITE_EA;
plen = sizeof nfs_aol_ffei;
p = (PFILE_FULL_EA_INFORMATION) &nfs_aol_ffei;
}
else if (pc.fs_is_nfs ())
{
/* When creating a file on an NFS share, we have to set the
- file mode by writing a NFS fattr3 structure with the
+ file mode by writing a NFS fattr3 structure with the
correct mode bits set. */
access |= FILE_WRITE_EA;
plen = sizeof (FILE_FULL_EA_INFORMATION) + sizeof (NFS_V3_ATTR)
p->EaValueLength = sizeof (fattr3);
strcpy (p->EaName, NFS_V3_ATTR);
fattr3 *nfs_attr = (fattr3 *) (p->EaName
- + p->EaNameLength + 1);
+ + p->EaNameLength + 1);
memset (nfs_attr, 0, sizeof (fattr3));
nfs_attr->type = NF3REG;
nfs_attr->mode = mode;
authenticating using a local user account on the sharing machine.
If the SIDs of the client machine are used, that's entirely
unexpected behaviour.
-
+
Doing it like we do here creates the expected SD in a domain as
well as on standalone servers. */
if ((flags & O_CREAT) && has_acls () && pc.isremote ())
case _PC_NAME_MAX:
/* NAME_MAX is without trailing \0 */
if (!pc.isdir ())
- return NAME_MAX;
+ return NAME_MAX;
ret = NT_MAX_PATH - strlen (get_name ()) - 2;
return ret < 0 ? 0 : ret > NAME_MAX ? NAME_MAX : ret;
case _PC_PATH_MAX:
select_record *select_read (select_record *s);
};
-struct wsa_event
+struct wsa_event
{
LONG serial_number;
long events;
int connect_errorcode;
pid_t owner;
-};
+};
class fhandler_socket: public fhandler_base
{
if (pc.fs_is_nfs ())
{
/* chmod on NFS shares works by writing an EA of type NfsV3Attributes.
- Only type and mode have to be set. Apparently type isn't checked
+ Only type and mode have to be set. Apparently type isn't checked
for consistency, so it's sufficent to set it to NF3REG all the time. */
struct {
FILE_FULL_EA_INFORMATION ffei;
if (!NT_SUCCESS (status))
__seterrno_from_nt_status (status);
else
- res = 0;
+ res = 0;
goto out;
}
persistent ACLs, FileDirectoryInformation otherwise.
NFS clients hide dangling symlinks from directory queries,
- unless you use the FileNamesInformation info class.
+ unless you use the FileNamesInformation info class.
On newer NFS clients (>=Vista) FileIdBothDirectoryInformation
works fine, but only if the NFS share is mounted to a drive
letter. TODO: We don't test that here for now, but it might
{
dir->__flags |= dirent_set_d_ino;
if (pc.fs_is_nfs ())
- dir->__flags |= dirent_nfs_d_ino;
+ dir->__flags |= dirent_nfs_d_ino;
else if (wincap.has_fileid_dirinfo ()
&& !pc.has_buggy_fileid_dirinfo ())
dir->__flags |= dirent_get_d_ino;
{
tmp_pathbuf tp;
UNICODE_STRING fbuf;
-
+
tp.u_get (&fbuf);
RtlCopyUnicodeString (&fbuf, pc.get_nt_native_path ());
RtlAppendUnicodeToString (&fbuf, L"\\");
{
FileName = ((PFILE_NAMES_INFORMATION) buf)->FileName;
FileNameLength = ((PFILE_NAMES_INFORMATION) buf)->FileNameLength;
- }
+ }
else
{
FileName = ((PFILE_DIRECTORY_INFORMATION) buf)->FileName;
LPSECURITY_ATTRIBUTES sa_buf =
sec_user ((PSECURITY_ATTRIBUTES) char_sa_buf, cygheap->user.sid());
mode |= FILE_FLAG_OVERLAPPED;
- HANDLE h = CreateNamedPipe(npname, mode, FIFO_PIPE_MODE,
- PIPE_UNLIMITED_INSTANCES, 0, 0,
- NMPWAIT_WAIT_FOREVER, sa_buf);
+
+ HANDLE h;
+ DWORD err;
+ bool nonblocking_write = !!((flags & (O_WRONLY | O_NONBLOCK)) == (O_WRONLY | O_NONBLOCK));
+ if (nonblocking_write)
+ {
+ h = INVALID_HANDLE_VALUE;
+ err = ERROR_ACCESS_DENIED;
+ }
+ else
+ {
+ h = CreateNamedPipe(npname, mode, FIFO_PIPE_MODE,
+ PIPE_UNLIMITED_INSTANCES, 0, 0,
+ NMPWAIT_WAIT_FOREVER, sa_buf);
+ err = GetLastError ();
+ }
if (h != INVALID_HANDLE_VALUE)
wait_state = fifo_wait_for_client;
else
- switch (GetLastError ())
+ switch (err)
{
case ERROR_ACCESS_DENIED:
h = open_nonserver (npname, low_flags, sa_buf);
wait_state = fifo_wait_for_server;
break;
}
+ if (nonblocking_write && GetLastError () == ERROR_FILE_NOT_FOUND)
+ {
+ set_errno (ENXIO);
+ break;
+ }
/* fall through intentionally */
default:
__seterrno ();
/* fhandler_netdrive.cc: fhandler for // and //MACHINE handling
- Copyright 2005 Red Hat, Inc.
+ Copyright 2005, 2006, 2007, 2008 Red Hat, Inc.
This file is part of Cygwin.
case GET_RESOURCE_ENUM:
nh = (struct net_hdls *) ndi->in;
if (!nh->dom)
- {
+ {
ndi->ret = ERROR_NO_MORE_ITEMS;
break;
}
else if (is_nonblocking () || err != WSAEWOULDBLOCK)
break;
}
-
+
if (sum)
res = sum;
else if (res == SOCKET_ERROR)
The essential code of the lf_XXX functions has been taken from the
module src/sys/kern/kern_lockf.c. It has been adapted to use NT
global namespace subdirs and event objects for synchronization
- purposes.
-
+ purposes.
+
So, the following copyright applies to most of the code in the lf_XXX
functions.
* SUCH DAMAGE.
*
* @(#)ufs_lockf.c 8.3 (Berkeley) 1/6/94
-*/
+*/
/*
* The flock() function is based upon source taken from the Red Hat
if (node)
{
bool no_locks_left =
- node->del_my_locks (after_fork ? 0 : get_unique_id (), get_handle ());
+ node->del_my_locks (after_fork ? 0 : get_unique_id (), get_handle ());
if (no_locks_left)
{
LIST_REMOVE (node, i_next);
continue;
short type = wcstol (endptr + 1, &endptr, 16);
if ((type != F_RDLCK && type != F_WRLCK) || !endptr || *endptr != L'-')
- continue;
+ continue;
_off64_t start = (_off64_t) wcstoull (endptr + 1, &endptr, 16);
if (start < 0 || !endptr || *endptr != L'-')
- continue;
+ continue;
_off64_t end = (_off64_t) wcstoull (endptr + 1, &endptr, 16);
if (end < -1LL || (end > 0 && end < start) || !endptr || *endptr != L'-')
- continue;
+ continue;
long long id = wcstoll (endptr + 1, &endptr, 16);
if (!endptr || *endptr != L'-'
|| ((flags & F_POSIX) && (id < 1 || id > ULONG_MAX)))
- continue;
+ continue;
DWORD wid = wcstoul (endptr + 1, &endptr, 16);
if (endptr && *endptr != L'\0')
- continue;
+ continue;
if (lock - i_all_lf >= MAX_LOCKF_CNT)
- {
+ {
system_printf ("Warning, can't handle more than %d locks per file.",
MAX_LOCKF_CNT);
break;
}
if (lock > i_all_lf)
- lock[-1].lf_next = lock;
+ lock[-1].lf_next = lock;
new (lock++) lockf_t (this, &i_all_lf, flags, type, start, end, id, wid);
}
/* If no lock has been found, return NULL. */
short a_flags = fl->l_type & (F_POSIX | F_FLOCK);
short type = fl->l_type & (F_RDLCK | F_WRLCK | F_UNLCK);
-
+
if (!a_flags)
a_flags = F_POSIX; /* default */
if (a_op == F_SETLKW)
a_op = F_UNLCK;
break;
case F_RDLCK:
- if (!(get_access () & GENERIC_READ))
+ if (!(get_access () & GENERIC_READ))
{
set_errno (EBADF);
return -1;
}
break;
case F_WRLCK:
- if (!(get_access () & GENERIC_WRITE))
+ if (!(get_access () & GENERIC_WRITE))
{
set_errno (EBADF);
return -1;
}
break;
default:
- set_errno (EINVAL);
+ set_errno (EINVAL);
return -1;
}
{
clean = new lockf_t ();
if (!clean)
- {
+ {
node->UNLOCK ();
set_errno (ENOLCK);
return -1;
case F_UNLCK:
error = lf_clearlock (lock, &clean, get_handle ());
lock->lf_next = clean;
- clean = lock;
+ clean = lock;
break;
-
+
case F_GETLK:
error = lf_getlock (lock, node, fl);
lock->lf_next = clean;
*/
static int
lf_setlock (lockf_t *lock, inode_t *node, lockf_t **clean, HANDLE fhdl)
-{
+{
lockf_t *block;
lockf_t **head = lock->lf_head;
lockf_t **prev, *overlap;
* do not go off into neverland.
*/
/* FIXME: We check the handle count of all the lock event objects
- this process holds. If it's > 1, another process is
+ this process holds. If it's > 1, another process is
waiting for one of our locks. This method isn't overly
intelligent. If it turns out to be too dumb, we might
have to remove it or to find another method. */
}
SetThreadPriority (GetCurrentThread (), priority);
if (lock->lf_flags & F_POSIX)
- {
+ {
HANDLE proc = OpenProcess (SYNCHRONIZE, FALSE, block->lf_wid);
if (!proc)
{
CloseHandle (proc);
}
else
- {
+ {
HANDLE w4[2] = { obj, signal_arrived };
node->UNLOCK ();
/* Unfortunately, since BSD flock locks are not attached to a
/* The lock object has been set to signalled. */
break;
case WAIT_OBJECT_0 + 1:
- /* For POSIX locks, the process holding the lock has exited. */
+ /* For POSIX locks, the process holding the lock has exited. */
if (lock->lf_flags & F_POSIX)
break;
/*FALLTHRU*/
*/
switch (ovcase)
{
- case 0: /* no overlap */
+ case 0: /* no overlap */
if (needtolink)
{
*prev = lock;
lock->lf_next = overlap;
lock->create_lock_obj ();
- }
- break;
+ }
+ break;
- case 1: /* overlap == lock */
+ case 1: /* overlap == lock */
/*
* If downgrading lock, others may be
* able to acquire it.
*clean = lock;
break;
- case 2: /* overlap contains lock */
+ case 2: /* overlap contains lock */
/*
* Check for common starting point and different types.
*/
lock->lf_next->create_lock_obj ();
break;
- case 3: /* lock contains overlap */
+ case 3: /* lock contains overlap */
/*
* If downgrading lock, others may be able to
* acquire it, otherwise take the list.
*clean = overlap;
continue;
- case 4: /* overlap starts before lock */
+ case 4: /* overlap starts before lock */
/*
* Add lock after overlap on the list.
*/
needtolink = 0;
continue;
- case 5: /* overlap ends after lock */
+ case 5: /* overlap ends after lock */
/*
* Add the new lock before overlap.
*/
switch (ovcase)
{
- case 1: /* overlap == lock */
+ case 1: /* overlap == lock */
*prev = overlap->lf_next;
overlap->lf_next = *clean;
*clean = overlap;
break;
- case 2: /* overlap contains lock: split it */
+ case 2: /* overlap contains lock: split it */
if (overlap->lf_start == unlock->lf_start)
{
overlap->lf_start = unlock->lf_end + 1;
overlap->lf_next->create_lock_obj ();
break;
- case 3: /* lock contains overlap */
+ case 3: /* lock contains overlap */
*prev = overlap->lf_next;
lf = overlap->lf_next;
overlap->lf_next = *clean;
*clean = overlap;
continue;
- case 4: /* overlap starts before lock */
- overlap->lf_end = unlock->lf_start - 1;
- prev = &overlap->lf_next;
- lf = overlap->lf_next;
+ case 4: /* overlap starts before lock */
+ overlap->lf_end = unlock->lf_start - 1;
+ prev = &overlap->lf_next;
+ lf = overlap->lf_next;
overlap->create_lock_obj ();
- continue;
+ continue;
- case 5: /* overlap ends after lock */
- overlap->lf_start = unlock->lf_end + 1;
+ case 5: /* overlap ends after lock */
+ overlap->lf_start = unlock->lf_end + 1;
overlap->create_lock_obj ();
- break;
+ break;
}
break;
}
*/
static lockf_t *
lf_getblock (lockf_t *lock, inode_t *node)
-{
+{
lockf_t **prev, *overlap;
lockf_t *lf = node->get_all_locks_list ();
int ovcase;
*
* NOTE: this returns only the FIRST overlapping lock. There
* may be more than one.
- */
+ */
static int
lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev,
lockf_t **overlap)
*prev = &lf->lf_next;
*overlap = lf = lf->lf_next;
continue;
- }
+ }
/*
* OK, check for overlap
*
*prev = &lf->lf_next;
*overlap = lf = lf->lf_next;
continue;
- }
+ }
if ((lf->lf_start == start) && (lf->lf_end == end))
{
/* Case 1 */
{
lockf_t *splitlock;
- /*
+ /*
* Check to see if spliting into only two pieces.
*/
if (lock1->lf_start == lock2->lf_start)
181: Export cygwin_conv_path, cygwin_create_path, cygwin_conv_path_list.
182: Export lockf.
FIXME: Removed 12 year old and entirely wrong wprintf function at
- this point. We need a working implementation soon.
+ this point. We need a working implementation soon.
183: Export open_memstream, fmemopen.
184: Export openat, faccessat, fchmodat, fchownat, fstatat, futimesat,
- linkat, mkdirat, mkfifoat, mknodat, readlinkat, renameat, symlinkat,
+ linkat, mkdirat, mkfifoat, mknodat, readlinkat, renameat, symlinkat,
unlinkat.
185: Export futimens, utimensat.
186: Remove ancient V8 regexp functions. Also eliminate old crt0 interface
- which provided its own user_data structure.
+ which provided its own user_data structure.
187: Export cfmakeraw.
188: Export CW_SET_PRIV_KEY.
*/
OBJECT_ATTRIBUTES attr;
NTSTATUS status;
ULONG flags = 0;
-
+
if (bInheritHandle)
flags |= OBJ_INHERIT;
if (lpName)
#define isproc(path) \
(path_prefix_p (proc, (path), proc_len, false))
-/* is_unc_share: Return non-zero if PATH begins with //server/share
- or with one of the native prefixes //./ or //?/
+/* is_unc_share: Return non-zero if PATH begins with //server/share
+ or with one of the native prefixes //./ or //?/
This function is only used to test for valid input strings.
The later normalization drops the native prefixes. */
nmounts = 0;
PWCHAR pathend;
WCHAR path[PATH_MAX];
-
+
pathend = wcpcpy (path, cygwin_shared->installation_root);
create_root_entry (path);
pathend = wcpcpy (pathend, L"\\etc\\fstab");
}
struct opt
-{
+{
const char *name;
unsigned val;
bool clear;
{
char *p = strchr (options, ',');
if (p)
- *p++ = '\0';
+ *p++ = '\0';
else
- p = strchr (options, '\0');
+ p = strchr (options, '\0');
for (opt *o = oopts;
o < (oopts + (sizeof (oopts) / sizeof (oopts[0])));
o++)
- if (strcmp (options, o->name) == 0)
- {
- if (o->clear)
- flags &= ~o->val;
- else
- flags |= o->val;
- goto gotit;
- }
+ if (strcmp (options, o->name) == 0)
+ {
+ if (o->clear)
+ flags &= ~o->val;
+ else
+ flags |= o->val;
+ goto gotit;
+ }
system_printf ("invalid fstab option - '%s'", options);
return false;
NT_MAX_PATH - (fstab_end - fstab),
cygheap->user.name ());
/* Make sure special chars in the username are converted according to
- the rules. */
+ the rules. */
transform_chars (username, username + wcslen (username) - 1);
}
RtlInitUnicodeString (&upath, fstab);
retry:
bool got_nl = false;
while (got < buf + len && (end = strchr (got, '\n')))
- {
+ {
got_nl = true;
end[end[-1] == '\r' ? -1 : 0] = '\0';
if (!from_fstab_line (got, user))
++line;
}
if (len < (sizeof (buf) - 2))
- break;
+ break;
/* Check if the buffer contained at least one \n. If not, the
- line length is > 32K. We don't take such long lines. Print
+ line length is > 32K. We don't take such long lines. Print
a debug message and skip this line entirely. */
if (!got_nl)
- {
+ {
system_printf ("%W: Line %d too long, skipping...", fstab, line);
while (NT_SUCCESS (NtReadFile (fh, NULL, NULL, NULL, &io, buf,
- (sizeof (buf) - 2), NULL, NULL)))
+ (sizeof (buf) - 2), NULL, NULL)))
{
len = io.Information;
buf[len] = buf[len + 1] = '\0';
got = strchr (buf, '\n');
if (got)
- {
+ {
++got;
++line;
goto retry;
break;
}
/* We have to read once more. Move remaining bytes to the start of
- the buffer and reposition got so that it points to the end of
+ the buffer and reposition got so that it points to the end of
the remaining bytes. */
len = buf + len - got;
memmove (buf, got, len);
strcpy (path, cygdrive);
/* Strip trailing slash for backward compatibility. */
if (cygdrive_len > 2)
- path[cygdrive_len - 1] = '\0';
+ path[cygdrive_len - 1] = '\0';
}
if (flags)
strcpy (flags, (cygdrive_flags & MOUNT_BINARY) ? "binmode" : "textmode");
for (i = 0; i < nmounts; i++)
{
if (!strcmp (mount[i].posix_path, posixtmp))
- {
+ {
/* Don't allow to override a system mount with a user mount. */
if ((mount[i].flags & MOUNT_SYSTEM) && !(mountflags & MOUNT_SYSTEM))
{
NFS_ACT_ON_LINK };
uint32_t nfs_type_mapping[] = { 0, S_IFREG, S_IFDIR, S_IFBLK,
- S_IFCHR, S_IFLNK, S_IFSOCK, S_IFIFO };
+ S_IFCHR, S_IFLNK, S_IFSOCK, S_IFIFO };
/* Specific ACCESS_MASKSs for objects created in Cygwin. */
#define CYG_SHARED_DIR_ACCESS (DIRECTORY_QUERY \
- | DIRECTORY_TRAVERSE \
- | DIRECTORY_CREATE_SUBDIRECTORY \
- | DIRECTORY_CREATE_OBJECT \
- | READ_CONTROL)
+ | DIRECTORY_TRAVERSE \
+ | DIRECTORY_CREATE_SUBDIRECTORY \
+ | DIRECTORY_CREATE_OBJECT \
+ | READ_CONTROL)
#define CYG_MUTANT_ACCESS (MUTANT_QUERY_STATE \
| SYNCHRONIZE \
NTSTATUS NTAPI NtCreateDirectoryObject (PHANDLE, ACCESS_MASK,
POBJECT_ATTRIBUTES);
NTSTATUS NTAPI NtCreateEvent (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
- EVENT_TYPE, BOOLEAN);
+ EVENT_TYPE, BOOLEAN);
NTSTATUS NTAPI NtCreateFile (PHANDLE, ACCESS_MASK, POBJECT_ATTRIBUTES,
PIO_STATUS_BLOCK, PLARGE_INTEGER, ULONG, ULONG,
ULONG, ULONG, PVOID, ULONG);
- /* path.cc: path support.
+/* path.cc: path support.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008 Red Hat, Inc.
&& FS_IS_SAMBA);
if (!is_samba ())
- {
+ {
is_netapp (RtlEqualUnicodeString (&fsname, &testname, FALSE)
&& FS_IS_NETAPP_DATAONTAP);
if (!is_nfs ())
{
/* Known remote file systems which can't handle calls to
- NtQueryDirectoryFile(FileIdBothDirectoryInformation) */
+ NtQueryDirectoryFile(FileIdBothDirectoryInformation) */
RtlInitUnicodeString (&testname, L"UNIXFS");
has_buggy_fileid_dirinfo (RtlEqualUnicodeString (&fsname,
&testname,
NTSTATUS status;
HANDLE fh;
tmp_pathbuf tp;
+ unsigned check_opt;
/* POSIX says that empty 'newpath' is invalid input while empty
'oldpath' is valid -- it's symlink resolver job to verify if
set_errno (ENOENT);
goto done;
}
+
+ check_opt = PC_SYM_NOFOLLOW | PC_POSIX | (isdevice ? PC_NOWARN : 0);
/* We need the normalized full path below. */
- win32_newpath.check (newpath, PC_SYM_NOFOLLOW | PC_POSIX, stat_suffixes);
+ win32_newpath.check (newpath, check_opt, stat_suffixes);
if (use_winsym && !win32_newpath.exists ()
&& (isdevice || !win32_newpath.fs_is_nfs ()))
{
char *newplnk = tp.c_get ();
stpcpy (stpcpy (newplnk, newpath), ".lnk");
- win32_newpath.check (newplnk, PC_SYM_NOFOLLOW | PC_POSIX);
+ win32_newpath.check (newplnk, check_opt);
}
if (win32_newpath.error)
/* The symlink target is relative to the directory in which
the symlink gets created, not relative to the cwd. Therefore
we have to mangle the path quite a bit before calling path_conv. */
- if (!isabspath (oldpath))
+ if (isabspath (oldpath))
+ win32_oldpath.check (oldpath,
+ PC_SYM_NOFOLLOW,
+ stat_suffixes);
+ else
{
len = strrchr (win32_newpath.normalized_path, '/')
- win32_newpath.normalized_path + 1;
oldpath);
win32_oldpath.check (absoldpath, PC_SYM_NOFOLLOW, stat_suffixes);
}
- else
- win32_oldpath.check (oldpath, PC_SYM_NOFOLLOW, stat_suffixes);
if (SUCCEEDED (SHGetDesktopFolder (&psl)))
{
WCHAR wc_path[win32_oldpath.get_wide_win32_path_len () + 1];
}
if (win32_newpath.has_acls () && win32_newpath.isremote ())
set_file_attribute (fh, win32_newpath, ILLEGAL_UID, ILLEGAL_GID,
- S_IFLNK | STD_RBITS | STD_WBITS);
+ S_IFLNK | STD_RBITS | STD_WBITS);
status = NtWriteFile (fh, NULL, NULL, NULL, &io, buf, cp - buf, NULL, NULL);
if (NT_SUCCESS (status) && io.Information == (ULONG) (cp - buf))
{
groups in the token, which are not in the group list set
with setgroups(). That's rather dangerous. What we're
really interested in is that all groups in the setgroups()
- list are in the token. A token created through ADVAPI
+ list are in the token. A token created through ADVAPI
should be allowed to contain more groups than requested
through setgroups(), esecially since Vista and the
addition of integrity groups. So we disable this statement
}
/* The key is not 0-terminated. */
- PWCHAR passwd = (PWCHAR) alloca (data->Length + sizeof (WCHAR));
+ PWCHAR passwd;
+ passwd = (PWCHAR) alloca (data->Length + sizeof (WCHAR));
*wcpncpy (passwd, data->Buffer, data->Length / sizeof (WCHAR)) = L'\0';
LsaFreeMemory (data);
debug_printf ("Try logon for %W\\%W", domain, user);
InitializeSecurityDescriptor (psd, SECURITY_DESCRIPTOR_REVISION);
PACL dacl = (PACL) (psd + 1);
InitializeAcl (dacl, MAX_DACL_LEN (1), ACL_REVISION);
- if (!AddAccessAllowedAce (dacl, ACL_REVISION, access,
+ if (!AddAccessAllowedAce (dacl, ACL_REVISION, access,
well_known_world_sid))
{
debug_printf ("AddAccessAllowedAce: %lu", GetLastError ());
_cygwin_testing ? cygwin_version.dll_build_date : "");
RtlInitUnicodeString (&uname, bnoname);
InitializeObjectAttributes (&attr, &uname, OBJ_INHERIT | OBJ_OPENIF,
- NULL, everyone_sd (CYG_SHARED_DIR_ACCESS));
+ NULL, everyone_sd (CYG_SHARED_DIR_ACCESS));
status = NtCreateDirectoryObject (&dir, CYG_SHARED_DIR_ACCESS, &attr);
if (!NT_SUCCESS (status))
- api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status);
+ api_fatal ("NtCreateDirectoryObject(%S): %p", &uname, status);
}
return dir;
-}
+}
HANDLE
get_session_parent_dir ()
if (!NT_SUCCESS (status) || psi.SessionId == 0)
dir = get_shared_parent_dir ();
else
- {
+ {
WCHAR bnoname[MAX_PATH];
__small_swprintf (bnoname,
L"\\Sessions\\BNOLINKS\\%d\\%s%s",
}
}
return dir;
-}
+}
char * __stdcall
shared_name (char *ret_buf, const char *str, int num)
else
{
shared_h = CreateFileMapping (INVALID_HANDLE_VALUE, psa,
- PAGE_READWRITE, 0, size, mapname);
+ PAGE_READWRITE, 0, size, mapname);
if (GetLastError () == ERROR_ALREADY_EXISTS)
m = SH_JUSTOPEN;
}
/* Correct the user name with what's defined in /etc/passwd before
loading the user fstab file. */
if (pw)
- cygheap->user.set_name (pw->pw_name);
+ cygheap->user.set_name (pw->pw_name);
user_shared->mountinfo.init (); /* Initialize the mount table. */
user_shared->cb = sizeof (*user_shared);
}
wascygexec = real_path.iscygexec ();
res = newargv.fixup (prog_arg, real_path, ext);
-
+
if (!real_path.iscygexec ()
&& (cygheap->cwd.drive_length == 0
|| cygheap->cwd.win32.Length >= MAX_PATH * sizeof (WCHAR)))
|| (runpath[5] != L':' /* UNC path */
&& len < (MAX_PATH + 6) * sizeof (WCHAR)))
{
- PWCHAR r = runpath + 4;
+ PWCHAR r = runpath + 4;
if (r[1] != L':') /* UNC path */
*(r += 2) = L'\\';
if (!RtlIsDosDeviceName_U (r))
the privileged user instead of using the orignal token. This can have
unfortunate side effects. The created token has different group
memberships, different user rights, and misses possible network
- credentials.
+ credentials.
Therefore we try this shortcut now. When switching back to the
privileged user, we probably always want a correct (aka original)
user token for this privileged user, not only in sshd. */
{
new_token = lsaprivkeyauth (pw_new);
if (new_token)
- {
+ {
/* We have to verify this token since settings in /etc/group
might render it unusable im terms of group membership. */
if (!verify_token (new_token, usersid, groups))
}
}
if (!new_token)
- {
+ {
debug_printf ("lsaprivkeyauth failed, try lsaauth.");
if (!(new_token = lsaauth (usersid, groups, pw_new)))
{
if (dirfd == AT_FDCWD)
p = stpcpy (path_ret, cygheap->cwd.posix);
else
- {
+ {
cygheap_fdget cfd (dirfd);
if (cfd < 0)
return -1;
p = stpcpy (path_ret, cfd->get_name ());
}
if (!p)
- {
+ {
set_errno (ENOTDIR);
return -1;
}
char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname))
return -1;
-
+
va_list ap;
mode_t mode;
if (flags & ~(F_OK|R_OK|W_OK|X_OK))
set_errno (EINVAL);
else
- {
+ {
fhandler_base *fh = build_fh_name (path, NULL,
(flags & AT_SYMLINK_NOFOLLOW)
? PC_SYM_NOFOLLOW : PC_SYM_FOLLOW,
- stat_suffixes);
+ stat_suffixes);
if (fh)
{
res = fh->fhaccess (mode);