--- devfsd-1.3.18.orig/devfsd.c +++ devfsd-1.3.18/devfsd.c @@ -721,6 +725,32 @@ SYSLOG (LOG_INFO, "read config file: \"%s\"\n", path); } /* End Function read_config_file */ +int internal_symlink(char *oldpath, char *newpath) +{ + struct stat buf; + + if(lstat(oldpath, &buf)) + { + SYSLOG(LOG_ERR, "Link destination \"%s\" doesn't exist.", oldpath); + return 0; + } + if(symlink(oldpath, newpath)) + { + if(errno == EEXIST) + { + char read_buf[MAXPATHLEN]; + if(!lstat(newpath, &buf) && (buf.st_mode & S_IFLNK)) + { + if(readlink(newpath, read_buf, MAXPATHLEN) > 0 && strcmp(read_buf, oldpath) == 0) + return 0; + } + } + SYSLOG(LOG_ERR, "Link \"%s\" to \"%s\" gives error %m.\n", oldpath, newpath); + + } + return 0; +} + static void process_config_line (CONST char *line, unsigned long *event_mask) /* [SUMMARY] Process a line from a configuration file. The configuration line. @@ -850,8 +880,12 @@ SYSLOG (LOG_ERR, "error loading: \"%s\"\t%s\n", p[0], dlerror () ); exit (1); } - new->u.function.func.m = - dlsym_nofail (p[0], new->u.function.so->handle, p[1]); + if ( strcmp(p[0], "GLOBAL") == 0 && strcmp(p[1], "symlink") == 0 ) + new->u.function.func.m = + dlsym_nofail (p[0], new->u.function.so->handle, "internal_symlink"); + else + new->u.function.func.m = + dlsym_nofail (p[0], new->u.function.so->handle, p[1]); --num_args; for (count = 0; count < num_args; ++count) {