Moving micasa 1.5 trunk to Novell forge.

This commit is contained in:
Cameron (Kamran) Mashayekhi
2005-10-11 19:51:00 +00:00
parent 082db33275
commit efe0a5e13c
691 changed files with 116628 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
#######################################################################
#
# Copyright (C) 2004 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Juan Carlos Luciani <jluciani@novell.com>
#
#######################################################################
if DEBUG
TARGET_CFG = Debug
else
TARGET_CFG = Release
endif
# handle Mono secondary dependencies
export MONO_PATH := $(MONO_PATH)
ModInstall_CFILES = $(srcdir)/modinstall.c
ModInstall_OBJ = modinstall.o
ModInstall_CSFILES_CSC :=
ModInstall_INCLUDES =
ModInstall_RESOURCES =
ModInstall_CFLAGS = $(CFLAGS)
ModInstall_LIBS =
ModInstall_LIBPATH =
EXTRA_DIST = $(ModInstall_CFILES)
CUR_DIR := $(shell pwd)
all: modinstall
modinstall: $(ModInstall_CFILES)
$(mkinstalldirs) bin/$(TARGET_CFG)
$(CC) -g -o bin/$(TARGET_CFG)/$@ $(ModInstall_CFILES)
install-exec-local: modinstall
$(mkinstalldirs) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) bin/$(TARGET_CFG)/modinstall $(DESTDIR)$(bindir)/
uninstall-local:
cd $(DESTDIR)$(bindir); rm -f modinstall
rmdir $(DESTDIR)$(bindir)
#installcheck-local: install
# $(mkinstalldirs) $(DESTDIR)$(bindir)
# $(INSTALL_PROGRAM) $(DESTDIR)$(bindir)
# cd $(DESTDIR)$(bindir); $(MONO)
CLEAN_FILES = bin/$(TARGET_CFG)/modinstall
clean-local:
rm -rf *.dbg *.exe *.so *.o *.dll $(CLEAN_FILES) $(COMMON_CLEAN_FILES)
distclean-local:
maintainer-clean-local:
rm -f Makefile.in

View File

@@ -0,0 +1,75 @@
#######################################################################
#
# Copyright (C) 2004 Novell, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This program 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Author: Juan Carlos Luciani <jluciani@novell.com>
#
#######################################################################
if DEBUG
TARGET_CFG = Debug
else
TARGET_CFG = Release
endif
# handle Mono secondary dependencies
export MONO_PATH := $(MONO_PATH)
PamMod_CFILES = $(srcdir)/pam_pwcapture.c
PamMod_OBJ = pam_pwcapture.o
PamMod_CSFILES_CSC :=
PamMod_INCLUDES =
PamMod_RESOURCES =
PamMod_CFLAGS = $(CFLAGS)
PamMod_LIBS =
PamMod_LIBPATH =
EXTRA_DIST = $(PamMod_CFILES)
CUR_DIR := $(shell pwd)
all: pam_pwcapture.so
pam_pwcapture.so: $(PamMod_CFILES)
$(mkinstalldirs) ../Common/$(TARGET_CFG)
$(mkinstalldirs) bin/$(TARGET_CFG)
$(CC) -shared -lpam -lpam_misc -o bin/$(TARGET_CFG)/$@ $(PamMod_CFILES)
cp bin/$(TARGET_CFG)/$@ ../Common/$(TARGET_CFG)/$@
install-exec-local: pam_pwcapture.so
$(mkinstalldirs) $(DESTDIR)$(libdir)
$(INSTALL_PROGRAM) bin/$(TARGET_CFG)/pam_pwcapture.so $(DESTDIR)$(libdir)/
uninstall-local:
cd $(DESTDIR)$(libdir); rm -f pam_pwcapture.so
rmdir $(DESTDIR)$(libdir)
#installcheck-local: install
# $(mkinstalldirs) $(DESTDIR)$(libdir)
# $(INSTALL_PROGRAM) $(DESTDIR)$(libdir)
# cd $(DESTDIR)$(libdir); $(MONO)
CLEAN_FILES = bin/$(TARGET_CFG)/pam_pwcapture.so
clean-local:
rm -rf *.dbg *.exe *.so *.o *.dll $(CLEAN_FILES) $(COMMON_CLEAN_FILES)
distclean-local:
maintainer-clean-local:
rm -f Makefile.in

View File

@@ -0,0 +1,304 @@
/***********************************************************************
* File: modinstall.c
* Author: Juan Carlos Luciani (jluciani@novell.com)
*
* Abstract: Implements a utility to install or un-install the
* pam_pwcapture module.
*
* Copyright (C) 2004 Novell, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
***********************************************************************/
#include "stdio.h"
#include "errno.h"
#include <unistd.h>
#include <getopt.h>
typedef int BOOL;
#define TRUE 1
#define FALSE 0
// Usage string
char usage[] = "\nmodinstall: usage: [-i InstallPamConfigFilePath] [-u UninstallPamConfigFilePath]\n";
// Our PAM Configuration Line
char pamConfigLine[] = "auth required\tpam_pwcapture.so\n";
/* ************************************************************************
* InstallModule()
*
* Installs the pam_pwcapture file in the specified file.
*
* ************************************************************************/
void
InstallModule(char *pFilePath)
{
FILE *fp;
FILE *fpTemp;
fpos_t currLinePosition;
char currLine[512];
BOOL authLineFound = FALSE;
BOOL insertedOurLine = FALSE;
// Open temporary file
if ((fpTemp = tmpfile()) != NULL)
{
// Open the PAM config file for reading
if ((fp = fopen(pFilePath, "r")) != NULL)
{
// Copy the PAM config file onto the temp file
while (fgets(currLine, 512, fp) != NULL)
if (fputs(currLine, fpTemp) < 0)
fprintf(stderr, "Error writing line to temp file\n");
// Close the PAM Config file and reopen it for writing
fclose(fp);
if ((fp = fopen(pFilePath, "w")) != NULL)
{
// Reset the file position on the temp file to the beginning
if (fseek(fpTemp, 0, SEEK_SET) == 0)
{
// Now move the lines from the temp file onto the clean
// PAM config file looking for a place to insert our own
// line.
while (fgets(currLine, 512, fpTemp) != NULL)
{
// Check if we are dealing with a line configuring an authentication service
if (strlen(currLine) > 4
&& tolower(currLine[0]) == 'a'
&& tolower(currLine[1]) == 'u'
&& tolower(currLine[2]) == 't'
&& tolower(currLine[3]) == 'h')
{
authLineFound = TRUE;
}
else
{
// This line is not configuring an authentication service, check if we
// now need to add a line for our module.
if (authLineFound && insertedOurLine == FALSE)
{
// Do not add our line if the line is commented out
if (strlen(currLine) > 1
&& currLine[0] != '#')
{
// Ok, now insert our line into the configuration.
if (fputs(pamConfigLine, fp) < 0)
fprintf(stderr, "Error writing line to PAM Config file\n");
insertedOurLine = TRUE;
}
}
}
if (fputs(currLine, fp) < 0)
fprintf(stderr, "Error writing line to PAM Config file\n");
}
}
else
{
fprintf(stderr, "Error resetting position in temp file\n");
}
// Close the PAM Config file
fclose(fp);
}
else
{
fprintf(stderr, "Error reopening PAM Config file\n");
}
}
else
{
fprintf(stderr, "Error opening PAM Config file for reading\n");
}
// Close the temporary file
fclose(fpTemp);
}
else
{
fprintf(stderr, "Unable to open temporary file\n");
}
}
/* ************************************************************************
* UninstallModule()
*
* Uninstalls the pam_pwcapture file from the specified file.
*
* ************************************************************************/
void
UninstallModule(char *pFilePath)
{
FILE *fp;
FILE *fpTemp;
char currLine[512];
// Open temporary file
if ((fpTemp = tmpfile()) != NULL)
{
// Open the PAM config file for reading
if ((fp = fopen(pFilePath, "r")) != NULL)
{
// Copy the PAM config file onto the temp file
while (fgets(currLine, 512, fp) != NULL)
if (fputs(currLine, fpTemp) < 0)
fprintf(stderr, "Error writing line to temp file\n");
// Close the PAM Config file and reopen it for writing
fclose(fp);
if ((fp = fopen(pFilePath, "w")) != NULL)
{
// Reset the file position on the temp file to the beginning
if (fseek(fpTemp, 0, SEEK_SET) == 0)
{
// Now move the lines from the temp file onto the clean
// PAM config file looking for our own line.
while (fgets(currLine, 512, fpTemp) != NULL)
{
// Write lines other than our own back to the PAM Config file
if (strcmp(currLine, pamConfigLine) != 0)
{
if (fputs(currLine, fp) < 0)
fprintf(stderr, "Error writing line to PAM Config file\n");
}
}
}
else
{
fprintf(stderr, "Error resetting position in temp file\n");
}
// Close the PAM Config file
fclose(fp);
}
else
{
fprintf(stderr, "Error reopening PAM Config file\n");
}
}
else
{
fprintf(stderr, "Error opening PAM Config file for reading\n");
}
// Close the temporary file
fclose(fpTemp);
}
else
{
fprintf(stderr, "Unable to open temporary file\n");
}
}
/* ************************************************************************
* main()
*
* Entry point for console application.
*
* ************************************************************************/
int main(int argc, char* argv[])
{
int option;
int optionsSpecified = 0;
BOOL doneScanning = FALSE;
BOOL invalidUsage = FALSE;
char *pInstallFile = NULL;
char *pUninstallFile = NULL;
// Scan options
while (!doneScanning)
{
opterr = 0;
option = getopt(argc, argv, "i:u:?");
// Proceed based on the result
switch (option)
{
case 'i':
// Install option, check the argument.
if (optarg != NULL)
{
// Record location of argument
pInstallFile = optarg;
optionsSpecified ++;
}
else
{
// No install file path specified
doneScanning = TRUE;
invalidUsage = TRUE;
}
break;
case 'u':
// Uninstall option, check the argument.
if (optarg != NULL)
{
// Record location of argument
pUninstallFile = optarg;
optionsSpecified ++;
}
else
{
// No uninstall file path specified
doneScanning = TRUE;
invalidUsage = TRUE;
}
break;
case '?':
// Invalid option detected
doneScanning = TRUE;
invalidUsage = TRUE;
break;
default:
// Done scanning
doneScanning = TRUE;
break;
}
}
// Do some sanity checking
if (!invalidUsage
&& optionsSpecified)
{
// Check if we need to install the module
if (pInstallFile)
{
InstallModule(pInstallFile);
}
// Check if we need to uninstall the module
if (pUninstallFile)
{
UninstallModule(pUninstallFile);
}
}
else
{
// Invalid option detected, print usage message.
printf(usage, argv[0]);
}
return 0;
}