Donation: cvspasswd utility

2000-07-07 Thread Steven M. Cherry

Hello all,

I was recently setting up my CVS server to add pserver access to it,
and when going through the documentation, it indicated that to set
up the cvs passwd file, you had to copy/paste the crypt'd password
into it.  It lamented the fact that there was no cvspasswd utility
and hoped that it might exist some day.

Assuming that the documentation is right and the utility does not
exist, I have taken the liberty of creating a small cvspasswd 
utility to cover this task.  It works much like the standard unix
system passwd utility.

I would like to donate this utility to the CVS community and will
agree to release it under whatever license is appropriate for this
group.

It is written in straight C and compiles with:

gcc -Wall -o cvspasswd cvspasswd -lcrypt

Let me know if you have questions or comments.

Steven

-- Begin Code: cvspasswd.c
/* ** */
/* This is the cvs passwd utility.  It functions in much the  */
/* same way that the normal unix passwd utility works.  The   */
/* cvs password file is expected to be:   */
/* $CVSROOT/CVSROOT/passwd*/
/* If the effective user id of the caller is = 0 (i.e. root)  */
/* then the user is allowed to change any password without*/
/* checking the password first.  If the user is anyone else,  */
/* they must first know the password of the user that they are*/
/* trying to change, and then they will be allowed to change  */
/* the password.  */
/* Called with no arguments, the utility will assume that the */
/* current user is trying to change his/her own password. */
/* Called with one argument, the argument is assumed to be the*/
/* name of the user whose password is to be changed.  */
/**/
/* Author: Steven M. Cherry   */
/* Revisions: */
/* 07/05/2000: SMC: Initial creation. */
/**/
/* ** */


#include 
#include 
#include 

#include 
#include 
#include 

#include 

#define SUCCESS 1
#define FAILURE 0

FILE  *glob_passwd_file;
char  **glob_passwd_contents;
int   glob_passwd_size;
char  *glob_username;
uid_t glob_userid;
char  *glob_cur_password;
char  glob_new_password[128];
int   glob_new_user_flag;
int   glob_line_count;

int find_and_open_passwd(void);
int who_am_i(void);
int check_args(int argc, char **argv);
int scan_to_user(void);
int do_password_check(void);
int get_new_password(void);
int update_passwd(void);
void free_mem(void);

int main (int argc, char **argv)
{
/* ** */
/* Check to find the passwd file: */
/* ** */
if(find_and_open_passwd() == FAILURE){
printf("Error opening password file!\n");
exit(1);
}

/* ** */
/* Check to see who we are.   */
/* ** */
if(who_am_i() == FAILURE){
fclose(glob_passwd_file);
printf("Unable to determine identity!\n");
exit(2);
}

/* ** */
/* Check our arguments.   */
/* ** */
if(check_args(argc, argv) == FAILURE){
fclose(glob_passwd_file);
printf("Argument error.\n");
exit(3);
}


/* ** */
/* Find the correct user in the file. */
/* Only the root user is allowed to add new people to */
/* the passwd file.   */
/* ** */
if(scan_to_user() == FAILURE){
fclose(glob_passwd_file);
free_mem();
printf("Error finding user in file.\n");
exit(4);
}

/* ** */
/* Perform password check first if necessary. */
/* ** */
if(do_password_check() == FAILURE){
fclose(glob_passwd_file);
free_mem();
printf("Invalid password.\n");  
exit(5);
}

/* ** */
/* Request new password, twice to con

Donation: cvspasswd utility (2nd try)

2000-07-07 Thread Steven M. Cherry

Having a bit of a problem trying to post to the list.  This is
the second try:

Hello all,

I was recently setting up my CVS server to add pserver access to it,
and when going through the documentation, it indicated that to set
up the cvs passwd file, you had to copy/paste the crypt'd password
into it.  It lamented the fact that there was no cvspasswd utility
and hoped that it might exist some day.

Assuming that the documentation is right and the utility does not
exist, I have taken the liberty of creating a small cvspasswd 
utility to cover this task.  It works much like the standard unix
system passwd utility.

I would like to donate this utility to the CVS community and will
agree to release it under whatever license is appropriate for this
group.

It is written in straight C and compiles with:

gcc -Wall -o cvspasswd cvspasswd -lcrypt

Let me know if you have questions or comments.

Steven

-- Begin Code: cvspasswd.c
/* ** */
/* This is the cvs passwd utility.  It functions in much the  */
/* same way that the normal unix passwd utility works.  The   */
/* cvs password file is expected to be:   */
/* $CVSROOT/CVSROOT/passwd*/
/* If the effective user id of the caller is = 0 (i.e. root)  */
/* then the user is allowed to change any password without*/
/* checking the password first.  If the user is anyone else,  */
/* they must first know the password of the user that they are*/
/* trying to change, and then they will be allowed to change  */
/* the password.  */
/* Called with no arguments, the utility will assume that the */
/* current user is trying to change his/her own password. */
/* Called with one argument, the argument is assumed to be the*/
/* name of the user whose password is to be changed.  */
/**/
/* Author: Steven M. Cherry   */
/* Revisions: */
/* 07/05/2000: SMC: Initial creation. */
/**/
/* ** */


#include 
#include 
#include 

#include 
#include 
#include 

#include 

#define SUCCESS 1
#define FAILURE 0

FILE  *glob_passwd_file;
char  **glob_passwd_contents;
int   glob_passwd_size;
char  *glob_username;
uid_t glob_userid;
char  *glob_cur_password;
char  glob_new_password[128];
int   glob_new_user_flag;
int   glob_line_count;

int find_and_open_passwd(void);
int who_am_i(void);
int check_args(int argc, char **argv);
int scan_to_user(void);
int do_password_check(void);
int get_new_password(void);
int update_passwd(void);
void free_mem(void);

int main (int argc, char **argv)
{
/* ** */
/* Check to find the passwd file: */
/* ** */
if(find_and_open_passwd() == FAILURE){
printf("Error opening password file!\n");
exit(1);
}

/* ** */
/* Check to see who we are.   */
/* ** */
if(who_am_i() == FAILURE){
fclose(glob_passwd_file);
printf("Unable to determine identity!\n");
exit(2);
}

/* ** */
/* Check our arguments.   */
/* ** */
if(check_args(argc, argv) == FAILURE){
fclose(glob_passwd_file);
printf("Argument error.\n");
exit(3);
}


/* ** */
/* Find the correct user in the file. */
/* Only the root user is allowed to add new people to */
/* the passwd file.   */
/* ** */
if(scan_to_user() == FAILURE){
fclose(glob_passwd_file);
free_mem();
printf("Error finding user in file.\n");
exit(4);
}

/* ** */
/* Perform password check first if necessary. */
/* ** */
if(do_password_check() == FAILURE){
fclose(glob_passwd_file);
free_mem();
printf("Invalid password.\n");  
exit(5);
}

/* *

Re: Donation: cvspasswd utility

2000-07-08 Thread Steven M. Cherry

Hi Brian,

> In article <2707175845.C9279@crisis>, "Steven M. Cherry" 
> <[EMAIL PROTECTED]> wrote:
> 
> > Hello all,
> > 

> 
> Here is a patch to Steven's utility that adds options to set the cvsroot dir,
> the password file name, the cvs user, and the system user.
> I added some other minor features too, see the code.
> 
> To patch, cd to where you have the original cvspasswd.c and run this:
> %patch -p0 < patch-file


I went ahead and manually applied your patch to my codeset.  Even after
resetting the tab vs. spaces thing patch still didn't work.  That's fine, 
though 'cause I had to fix one or two bugs in it anyway. :)

So, here is the current version, along with a patch to go from my original
to this current version.  I've tar.gz'd the two so hopefully a binary
post here is o.k.  If not, holler and I'll repost in text only.

Steven


-- 
==
== Steven M. Cherry   [EMAIL PROTECTED]  ==
==   http://216.59.115.58/steven/home.html  ==
==

 cvspasswd.tar.gz


Re: Donation: cvspasswd utility - some changes

2000-07-10 Thread Steven M. Cherry

Hi Johan,

> Hi all,
> 
> I made some little changes to the sources.
> (included is the new c-file and the patch against the tarred version)
> 
> * function who_am_i : changed the curr_user->pw_passwd to curr_user->pw_name
> * function find_anf_open_passwd :
>-- option -d seemed not working, always overruled by $CVSROOT  (fixed it)
>-- added check for :pserver: in $CVSROOT and exit if found. (this means the 
> passwd cannot been changed using the pserver method.
>
> It seems to work with me when doing the folowing steps  :
> 
> * checkout the CVSROOT/passwd file
> * cvspasswd -d "PATH TO DIR WHERE CVSROOT IS EXTRACTED"
> * checkin the CVSROOT/passwd
> 
> Since we don't have direct access to the repository, this was the only way to do 
> it.  
> 
> Since root != cvs administator, I'm thinking of changing the root behaviour of 
> cvspasswd.  I know this is not secure at all, but for our sites non root users 
> should be able to add new users.  
> 
> I hope this helped a little, and thanks for the effort.
> 
> Johan
>
> 

Thanks for the patch.  I have updated my sources and am including the
latest c file and a unified diff version of your patch.  I appreciate the
feedback, and am glad this is usefull to people.

As far as the root behaviour of not allowing to add new users, I could
really go either way with the cvspasswd utility.  It's really the permissions
on the actual passwd file that dictate who can change/update it and who cannot.
These permissions will always override what the utility will try and
let you do.  I guess I just wanted an extra check in the utility that
would keep you from doing something accidentally that you didn't want.

Let me know what you think,

Steven


-- 
==
== Steven M. Cherry   [EMAIL PROTECTED]  ==
==   http://216.59.115.58/steven/home.html  ==
==

 cvspasswd.tar.gz


Re: Applying cvs diff's to the repository.

2000-07-10 Thread Steven M. Cherry

Hi David,

> Hello,
> 
> I am working on an open source project and I had a user give me a diff of
> the changes he made to a file.
> 
> I know it is possible to use the diff file to apply the changes to the
> version in the repository but I have no idea how.  Can anyone help me?
> 
> Thank in advance!
> 
> David
> 

The easiest way to do this is if the user will supply the diff output
in unified diff format (diff -u old.file new.file > patch).  Then all
you have to do is go to where you have the source file, and apply:

patch -p0 < patch

This will (if everything goes correctly) update your version of the file
with all of the changes that were submitted.  You may then cvs update/
cvs commit at your leisure.

Steven

-- 
==========
== Steven M. Cherry   [EMAIL PROTECTED]  ==
==   http://216.59.115.58/steven/home.html  ==
==




Re: CVS security

2000-07-20 Thread Steven M . Cherry

Hi Hal,

> Greetings!

> great, but it works ok.  Sure wish there was a "cvs passwd" command... ;)

There is!  It's been recently created and donated to cvs.  Find it here:
http://www.cherrys.org/steven/projects.html

Let me know what you think,

Steven

-- 
==========
== Steven M. Cherry   [EMAIL PROTECTED]  ==
== http://www.cherrys.org/steven/home.html  ==
==