dhcpd?
Alex Tang
altitude@airflash.com
Tue Feb 27 09:40:00 GMT 2001
Hi folks.
I was wondering, has anyone tried porting the ISC dchpd (version 2) to
cygwin?
If someone has this working, please let me know and ignore the rest of
this message. :-)
I retrieved the dhcpd source from their CVS server (cvs co -r RELEASE_2
DHCP from their server), and made some minor modifications to it to
remove the winsock stuff and make it use "normal" networking code. The
compilation works fine (diffs are included below), however when the app
is trying to do a rename(), it ALWSAYS gets a "permission denied".
I am using the cygwin 1.1.8 DLL.
The code chunk is included below:
void new_lease_file ()
{
char newfname [512];
char backfname [512];
TIME t;
int db_fd;
/* If we already have an open database, close it. */
if (db_file) {
fclose (db_file);
}
/* Make a temporary lease file... */
GET_TIME (&t);
sprintf (newfname, "%s.%d", path_dhcpd_db, (int)t);
db_fd = open (newfname, O_WRONLY | O_TRUNC | O_CREAT, 0664);
if (db_fd < 0) {
error ("Can't create new lease file: %m");
}
if ((db_file = fdopen (db_fd, "w")) == NULL) {
error ("Can't fdopen new lease file!");
}
/* Write an introduction so people don't complain about time
being off. */
fprintf (db_file, "# All times in this file are in UTC (GMT), not %s",
"your local timezone. This is\n");
fprintf (db_file, "# not a bug, so please don't ask about it. %s",
"There is no portable way to\n");
fprintf (db_file, "# store leases in the local timezone, so please %s",
"don't request this as a\n");
fprintf (db_file, "# feature. If this is inconvenient or %s",
"confusing to you, we sincerely\n");
fprintf (db_file, "# apologize. Seriously, though - don't ask.\n");
fprintf (db_file, "# The format of this file is documented in the %s",
"dhcpd.leases(5) manual page.\n\n");
/* Write out all the leases that we know of... */
counting = 0;
write_leases ();
/* Get the old database out of the way... */
sprintf (backfname, "%s~", path_dhcpd_db);
if (unlink (backfname) < 0 && errno != ENOENT)
error ("Can't remove old lease database backup %s: %m",
backfname);
if (link (path_dhcpd_db, backfname) < 0)
error ("Can't backup lease database %s to %s: %m",
path_dhcpd_db, backfname);
/* Move in the new file... */
if (rename (newfname, path_dhcpd_db) < 0)
error ("Can't install new lease database %s to %s: %m",
newfname, path_dhcpd_db);
counting = 1;
}
The last block (after "Move in the new file") always returns a -1 and
the errno is EACCES.
If i try to manually move the files from the shell, it works fine. The
permissions on all of the directories look fine (all directories are
owned by me, and I'm running the dhcpd as me.)
This is probably something butt-stupid that I'm doing. however I can't
see it.
Does anyone have any insights?
Thanks very much.
...alex...
diffs for dhcpd to make it compile, and cygcheck are included below...
More information about the Cygwin
mailing list