1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00
libvirt/tests/nssmock.c
Daniel P. Berrangé 600462834f Remove all Author(s): lines from source file headers
In many files there are header comments that contain an Author:
statement, supposedly reflecting who originally wrote the code.
In a large collaborative project like libvirt, any non-trivial
file will have been modified by a large number of different
contributors. IOW, the Author: comments are quickly out of date,
omitting people who have made significant contribitions.

In some places Author: lines have been added despite the person
merely being responsible for creating the file by moving existing
code out of another file. IOW, the Author: lines give an incorrect
record of authorship.

With this all in mind, the comments are useless as a means to identify
who to talk to about code in a particular file. Contributors will always
be better off using 'git log' and 'git blame' if they need to  find the
author of a particular bit of code.

This commit thus deletes all Author: comments from the source and adds
a rule to prevent them reappearing.

The Copyright headers are similarly misleading and inaccurate, however,
we cannot delete these as they have legal meaning, despite being largely
inaccurate. In addition only the copyright holder is permitted to change
their respective copyright statement.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-12-13 16:08:38 +00:00

137 lines
2.9 KiB
C

/*
* Copyright (C) 2016 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifdef NSS
# include "virmock.h"
# include <sys/types.h>
# include <dirent.h>
# include <sys/stat.h>
# include <fcntl.h>
# include <unistd.h>
# include "configmake.h"
# include "virstring.h"
# include "viralloc.h"
static int (*real_open)(const char *path, int flags, ...);
static DIR * (*real_opendir)(const char *name);
static int (*real_access)(const char *path, int mode);
# define LEASEDIR LOCALSTATEDIR "/lib/libvirt/dnsmasq/"
/*
* Functions to load the symbols and init the environment
*/
static void
init_syms(void)
{
if (real_open)
return;
VIR_MOCK_REAL_INIT(open);
VIR_MOCK_REAL_INIT(opendir);
VIR_MOCK_REAL_INIT(access);
}
static int
getrealpath(char **newpath,
const char *path)
{
if (STRPREFIX(path, LEASEDIR)) {
if (virAsprintfQuiet(newpath, "%s/nssdata/%s",
abs_srcdir,
path + strlen(LEASEDIR)) < 0) {
errno = ENOMEM;
return -1;
}
} else {
if (VIR_STRDUP_QUIET(*newpath, path) < 0)
return -1;
}
return 0;
}
int
open(const char *path, int flags, ...)
{
int ret;
char *newpath = NULL;
init_syms();
if (STRPREFIX(path, LEASEDIR) &&
getrealpath(&newpath, path) < 0)
return -1;
if (flags & O_CREAT) {
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = (mode_t) va_arg(ap, int);
va_end(ap);
ret = real_open(newpath ? newpath : path, flags, mode);
} else {
ret = real_open(newpath ? newpath : path, flags);
}
free(newpath);
return ret;
}
DIR *
opendir(const char *path)
{
DIR *ret;
char *newpath = NULL;
init_syms();
if (STRPREFIX(path, LEASEDIR) &&
getrealpath(&newpath, path) < 0)
return NULL;
ret = real_opendir(newpath ? newpath : path);
free(newpath);
return ret;
}
int
access(const char *path, int mode)
{
int ret;
char *newpath = NULL;
init_syms();
if (STRPREFIX(path, LEASEDIR) &&
getrealpath(&newpath, path) < 0)
return -1;
ret = real_access(newpath ? newpath : path, mode);
free(newpath);
return ret;
}
#else
/* Nothing to override if NSS plugin is not enabled */
#endif