/****************************************************************************** * TMBOSubmit.cpp - description * ------------------- * begin : 2005/04/20 * copyright : (C) 2005 by Harald K. Strack * copyright : (C) 2005 by Trymedia Inc. * email : hstrack@trymedia.com ****************************************************************************** * changes name date comment * hks 2005/05/25 Mask support added. Chmod(). */ /* TMBOSubmit: Trymedia Handler for the ap4 submit command * * This handler will be filled up with all filenames by a filesys hook * (see TMFSHook.cpp). It gets the actual changelist nuber from * TMSubmitClient::Message(). * * With this data it can perform any actions an any files after the submit call. * * FIXME: * It uses the same connection as the submit call itself, but the changes * are not atomic. What can we do here? Blocking all signals (Ctrl-C)? * */ #include "TMBOSubmit.h" TMBOSubmit::TMBOSubmit() : TMBO () { } /* I start the processing here - just for fun */ TMBOSubmit::~TMBOSubmit() { Run(); } /* String for errormessages */ StrBuf & TMBOSubmit::GetDescription () { StrBuf * buf = new StrBuf; buf->Set ("TRYMEDIA SUBMIT HANDLER"); return *buf; } /* Iterates over all filenames. * Creates a versioned filename from the known changelist number. * Reads the permission, uid, gid from a file. * Sets some attributes (permission, uid, gid) in p4d. * */ void TMBOSubmit::Run (Error *e = NULL) { struct stat attributes; //Start iteration fileNode * tmpNode = head; while (tmpNode != NULL) { //Worst case, should never happen if (data->GetPath(tmpNode) == NULL) { cerr << "Fatal: " << GetDescription ().Text() << "Programming error. Found a node without path." "Abort." << endl; exit (1); } //The path StrBuf path = *(data->GetPath(tmpNode)); //The versioned path StrBuf vpath; if (this->cl == NULL) { cerr << "Error: " << GetDescription ().Text() << " No changenumber found at Node: " << path.Text() << ". Giving up." << endl; exit (1); } else { vpath << path << "@" << this->cl; } //FileSys::Stat does not read enough. FIXME if multithreaded, need lock here. errno=0; if (lstat (path.Text(), &attributes) != 0) { int tmp=errno; errno=0; if (e != NULL) { SetErrorMsg (e, E_FATAL,"Fatal: %s: lstat: %s - %s\n", GetDescription ().Text(),path.Text(),strerror(tmp)); } else { cerr << "Fatal: " << GetDescription ().Text() << " lstat: " << path.Text() << " - " << strerror(tmp) << endl; } tmpNode = tmpNode->next; continue; } StrBuf attr; //Permission setting StrBuf st_mode; st_mode << attributes.st_mode; attr = TM_PERMISSION_ATTR; if (SendP4Attribute (&vpath, &attr, &st_mode) != TM_SUCCESS) { cerr << "Fatal: Giving up." << endl; exit (1); } //uid setting struct passwd * pwd; errno=0; if ((pwd = getpwuid (attributes.st_uid)) == NULL) { int tmp=errno; errno=0; if (e != NULL) { SetErrorMsg (e, E_FATAL,"Fatal: %s: getpwuid: %s - %s\n", GetDescription ().Text(), path.Text(),strerror(tmp)); } else { cerr << "Fatal: " << GetDescription ().Text() << " getpwuid: " << path.Text() << " - " << strerror(tmp) << endl; } tmpNode = tmpNode->next; continue; } StrBuf pw_name; attr = TM_USER_ATTR; pw_name << pwd->pw_name; if (SendP4Attribute (&vpath, &attr, &pw_name) != TM_SUCCESS) { cerr << "Fatal: Giving up." << endl; exit (1); } //gid setting struct group * grp; errno=0; if ((grp = getgrgid (attributes.st_gid)) == NULL) { int tmp=errno; errno=0; if (e != NULL) { SetErrorMsg (e, E_FATAL,"Fatal: %s: getgrgid: %s - %s\n", GetDescription ().Text(),path.Text(),strerror(tmp)); } else { cerr << "Fatal: " << GetDescription ().Text() << " getgrgid: " << path.Text() << " - " << strerror(tmp) << endl; } tmpNode = tmpNode->next; continue; } StrBuf gr_name; attr = TM_GROUP_ATTR; gr_name << grp->gr_name; if (SendP4Attribute (&vpath, &attr, &gr_name) != TM_SUCCESS) { cerr << "Fatal: Giving up." << endl; exit (1); } //next Element tmpNode = tmpNode->next; } } void TMBOSubmit::Chmod (TMFSHook * f, Error * e) { mode_t mode = f->GetMode (e); #ifndef FULL_PERMS mode &= 0555; //Set a-w #endif f->SetMode (mode,e); }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 5056 | harald_strack |
Directory support. Serious bug concerned to not unzipped binaries removed. Some other small bugfixes. |
||
#4 | 4980 | harald_strack |
Since I am maintaining the stuff in a local repository, I did some copy errors in the last revisions. Fixed. |
||
#3 | 4978 | harald_strack |
ap4 integrate implemented. Octal format is now used to save permissions. NOT backwards compatible anymore!!! |
||
#2 | 4975 | harald_strack |
Permissions are now masked to 555, so no write is possible. If you edit the Makefile and give the parameter -DFULL_PERMS, you have the old behaviour. Bugfix in ap4 revert: Edited and changed files were not reverted correctly. |
||
#1 | 4948 | harald_strack | Initial revision. |