Perforce 2000.1 System Administrator's Guide (2000.1.sa.3) | ||
<< Previous Chapter Supporting Perforce: Backup and Recovery |
Table of Contents Index Perforce on the Web |
Next Chapter >> Administering Perforce: Protections |
Each of the tasks described in this chapter requires that you be a Perforce superuser as defined in the Perforce protections table. For more about controlling Perforce superuser access, and protections in general, see "Administering Perforce: Protections" on page 43.
p4 user -f username
Fill in the form fields with the information for the user you wish to create.
The p4 user command also has an option (-i) to take its input from the standard input instead of the forms editor; if you wish to create a large number of new users at once, you could write a script which creates output in the same format as that used by the forms editor and then pipes each pre-generated "form" to p4 users -i -f username, where the username is also specified by a variable within your calling script.
You can create a Perforce group by using:
p4 group groupname
and adding users in the Users: field of the resulting form, one per line.
To grant write access to only those users in the newly-created group, use p4 protect and edit the protections table. The relevant line of the default protections table looks like this:
write user * * //...
It grants write permission to all users in all areas of the depot. After using p4 group groupname to create the Perforce group groupname, use p4 protect to change the protections table to read:
write group groupname * //...
This will restrict write access only to users who are part of the Perforce group groupname. Other users will not be able to automatically create new Perforce users until they have been added to this group. For a more in-depth treatment of Perforce protections, see "Administering Perforce: Protections" on page 43.
For example, if the output of p4 opened shows:
//depot/main/code/file.c#8 - edit default change (txt) by jim@stlouis
the "stlouis" client spec can be deleted with:
p4 client -d -f stlouis
Deleting a client spec reverts all files opened by that client, and removes that client's "have list". Note that it does not affect any files in the workspace actually used by that client; the files can still be accessed by other employees.
Because p4 delete merely marks files as deleted in their head revisions, it can't be used to free up diskspace. This is where p4 obliterate can be useful. p4 obliterate filename can be used by superusers to remove all traces of a file from a depot, making the file indistinguishable from one that never existed in the first place.
In fact, p4 obliterate is so destructive that we haven't even told you how it really works yet. By default, p4 obliterate filename does nothing; it merely reports on what it will do; to actually destroy the files, use p4 obliterate -y filename.
There is an additional flag to p4 obliterate; the -z flag. When you branch a file from one area of the depot into another, a "lazy copy" is created - the file itself isn't copied, only a record that the branch has occurred. If, for some reason, you wish to undo the "lazy copy" and create a new copy of the branched file's contents in your depot subdirectories, you could "obliterate" the lazy copy and create a new one by using p4 obliterate -z filename. Unlike the -y flag, the -z flag increases diskspace usage by removing the lazy copies. It's generally not a flag you'll use often; its only use is to undo lazy copies in order to allow you to manually remove archive files without breaking any linked metadata pointing to the deleted files.
If a user sees the following error message while trying to access files:
Operation:user-sync
where path is the path of a previously-obliterated file, odds are the user has encountered a problem that resulted from an earlier use of p4 obliterate from an older (pre-98.2/10314) Perforce server. Contact Perforce technical support for a workaround.
Librarian checkout path failed
The -f flag can also be used to delete any submitted changelists that have been emptied of files with p4 obliterate. The full syntax is p4 change -d -f changenumber.
Use p4 change with the -f (force) flag:
p4 change -f 123
p4 change -d -f 124
The User: and Description: fields for change 123 will be edited, and change 124 will be deleted.
To generate signatures and store them in the Perforce database, use the -u flag. Subsequent verifications will be compared against the stored signatures; if a new signature does not match the signature in the Perforce database for that file revision, Perforce adds the characters BAD! after the signature.
If you ever see a BAD! signature during a p4 verify command, your database or versioned files may have been corrupted, and you should contact Perforce Technical Support.
Because subsequent verifications can only be performed against previously stored signatures, the p4 verify -u command should be used regularly. A good strategy, for instance, might be to run p4 verify on a nightly basis before performing your system backups, proceeding with the backup only if the p4 verify reports no corruption. Generation and storage of new checksums (p4 verify -u) following a successful p4 verify could be performed nightly, or even weekly.
In previous releases, Perforce automatically determined if a file was of type text or binary based on an analysis of the first 1024 bytes of a file. If the high bit was clear in each of the first 1024 bytes, Perforce assumed it to be text; otherwise, it was binary. Although this default behavior could be overridden by the use of the -t filetype flag, it was easy to overlook this, particularly in cases where files' types were usually (but not always!) detected correctly.
The p4 typemap command solves this problem by allowing system administrators to set up a table that links Perforce file types with file name specifications. If an entry in the typemap table matches an entry in the table, it will override the file type that would otherwise have been assigned by the Perforce client.
One common use for p4 typemap is for users dealing with Adobe PDF (Portable Document Format) files. Some PDF files start with a series of comment fields and textual data, and if the comments are sufficiently long, the files will be erroneously detected by Perforce as being of type text. Similarly, files in RTF (Rich Text Format) format may sometimes be erroneously detected as text.
Perforce superusers may use p4 typemap to tell the Perforce server to regard all such files as binary by modifying the typemap table as follows:
The first three periods ("...") in the specification are a Perforce wildcard specifying that all files beneath the root directory are to be included as part of the mapping. The fourth period and the file extension specify that the specification applies to files ending in ".pdf" (or ".rtf")
For more information, see the p4 typemap page in the Command Reference.
The port on which the server listens is specified when the server is started. The number is arbitrary, so long as it does not conflict with any other networking services and is greater than 1024. The port number on the client machine is dynamically allocated.
A firewall is a network element which prevents any packets from outside a local (trusted) network from reaching that local network. This is done at a low level in the network protocol; any packets not coming from a trusted IP address are simply ignored.
In the following diagram, the Perforce client is on an untrusted part of the network. None of its connection requests will reach the machine with the Perforce server. Consequently, the user running the client through the firewall is unable to use Perforce.
Secure shell (ssh) is meant to be a replacement for the UNIX rsh (remote shell) command, which allows you to log into a remote system and execute commands on it. The "secure" part of "secure shell" comes from the fact that the connection is encrypted, so none of the data is visible while it passes through the untrusted network. With simple utilities like rsh, all traffic - even passwords - is unencrypted and visible to all intermediate hosts, creating an unacceptable security hazard.
Secure shell is available for free in source form for a multitude of UNIX platforms from http://www.ssh.org. This page also links to ports of ssh for OS/2 and Amiga, as well as commercial implementations for Windows and Macintosh from Data Fellows (http://www.datafellows.com). More information can be found at the Open SSH page (http://www.openssh.org).
The ssh FAQ (Frequently Asked Questions) list can also be found online, either at the main site (http://www.uni-karlsruhe.de/~ig25/ssh-faq), or at the FAQ archive at MIT: (ftp://rtfm.mit.edu/pub/usenet/news.answers/computer-security/ssh-faq).
A good solution takes advantage of ssh's ability to forward arbitrary TCP/IP connections. By using ssh, you can make your Perforce client appear as though it's connecting from the firewall machine over the local (trusted) network. In reality, your client remains on your local machine, but all packets from your local machine are first sent to the firewall through the secure channel set up by ssh:
Suppose the Perforce server is on p4dbox.bigcorp.com, and the firewall machine is called firewall.bigcorp.com. In our example, we'll arbitrarily choose local port 4242, and assume that the Perforce server is listening on port 3710.
Packets ultimately destined for your client's port 4242 are first sent to the firewall, and ssh forwards them securely to your client. Likewise, connections made to port 4242 of the firewall machine will end up being routed to port 3710 of the Perforce server.
On UNIX, the ssh command on our own machine to set up and forward the TCP/IP connection would be:
ssh -L 4242:p4dbox.bigcorp.com:3710 firewall.bigcorp.com
At this point, it may be necessary to provide a password to log into firewall.bigcorp.com. Once the connection is established, ssh will listen at port 4242 on the local machine, and forward anything it is told over its encrypted connection to firewall.bigcorp.com, and the firewall will then forward them by normal channels to port 3710 on p4dbox.bigcorp.com
All that remains is to tell the Perforce client to use port 4242 by setting the environment variable P4PORT to 4242.
Normally, setting P4PORT=4242 would normally indicate that we are trying to connect to a Perforce server on the local machine listening at port 4242. In this case, ssh takes the role of the Perforce server. Anything a client sends to port 4242 of the local machine is forwarded by ssh to the firewall, which passes it to the real Perforce server at p4dbox.bigcorp.com. Since all of this is transparent to the Perforce client, it doesn't matter whether the client is talking to an instance of ssh that's forwarding traffic from port 4242 of the local machine, or if it's talking to a real Perforce server residing on the local machine.
The only glitch is that there's a login session you don't normally want on the firewall machine. This can be solved by running
ssh -n -L 4242:p4dbox.bigcorp.com:3710 firewall.bigcorp.com sleep 9999999 &
on the remote system.
This tells ssh on firewall.bigcorp.com to run the sleep command for a very long time. The -n flag tells ssh not to read from stdin, and the & tells the OS to run the process in the background. Effectively, this sets up the ssh link and keeps it up; there is no login session to terminate.
Finally, ssh can be configured to "do the right thing" so that it is unnecessary to type such a long command with each session. The Windows version of ssh, for instance, has a GUI to configure this.
One final concern: with port 4242 on the local machine now forwarded to a supposedly-secure server, your local machine is part of the trusted network; it is prudent to make sure the local machine really is secure! The Windows version of ssh has an option to only allow local connections to the forwarded port, which is a wise precaution; your machine will be able to use port 4242, but a third party's machine will be ignored.
If, however, you specify both an IP address and a port number in P4PORT when starting p4d, the Perforce server will take the IP address into account, ignoring requests from any IP addresses other than the one specified in P4PORT.
Although this isn't the default behavior, it can be useful, for instance, if you want to tell p4d to listen only to a specific network interface or IP address. For instance, by setting P4PORT=localhost:port, you can make your Perforce server ignore all non-local connection requests.
If you wish to do this, add the following line to /etc/inetd.conf:
p4dservice stream tcp nowait username /usr/local/bin/p4d p4d -i -rp4droot
and add the following to /etc/services:
This method is an alternative to running p4d from a startup script. It can also be useful for providing special services; for example, at Perforce, we have a number of test servers running on UNIX, each defined as an inetd service with its own port number.
There are caveats with this method:
To summarize: the Perforce server on UNIX supports case-sensitive names. The Perforce server on NT ignores case differences. Case is always ignored in keyword-based job searches:
Case-sensitive |
UNIX server |
NT server |
---|---|---|
Pathnames and filenames |
Yes |
No |
Database entities (clients, labels, etc.) |
Yes |
No |
Job search keywords |
No |
No |
Users can run p4 info to find out what platform their Perforce server runs on.
Conversely, Windows users will have to be careful to use case consistently in file and path names when adding new files. They may not realize that files added as //depot/main/foo.c and //depot/MAIN/bar.c will appear in two different directories in a UNIX user's workspace.
The UNIX Perforce server always respects case in client names, label names, branch view names, etc. Windows users connecting to a UNIX server should be aware that the lowercased workstation names are used as the default names for new client workspaces. For examples, if a new user creates a client spec on an NT workstation named ROCKET, his client workspace will be named rocket by default. If he later sets P4CLIENT to ROCKET (or Rocket), Perforce will tell him his client is undefined. He must set P4CLIENT to rocket (or unset it) to use the client workspace he defined.
p4 add foo/file1
should be aware that all three files will be stored in the same depot directory. The depot path and filenames assigned to the NT server will be those first referenced. (in this case, the depot path name would be foo, and not FOO.
p4 add foo/file2
p4 add FOO/file3
p4d -r /usr/perforce -v server=1 -p 1666 -L /usr/perforce/logfile
Trace output will appear in the specified log file, and will show the date, time, username, IP address, and command for each request processed by the server. You should make that you have adequate diskspace before turning on logging.
In most cases, the Perforce server trace flags are useful only to administrators working with Perforce Technical Support to diagnose or investigate a problem.
The Perforce server stores two types of data under the Perforce root directory: versioned files and a database containing metadata describing those files. Your versioned files are the ones created and maintained by your users, and your database is a set of Perforce-maintained binary files holding the history and present state of the versioned files. In order to move a Perforce server to a new machine, both the versioned files and the database must be successfully migrated from the old machine to the new machine.
For more about the distinction between versioned files and database, as well as for an overview of the backup and restore procedure in general, see "Backup and Recovery Concepts" on page 19.
While the versioned files are portable across architectures, the database, as stored in the db.* files, is not. To overcome this problem, create a checkpoint of your Perforce server database and use that checkpoint to recreate the database on the new machine. The checkpoint is a text file which can be read by a Perforce server on any architecture. For more details, see "Creating a Checkpoint" on page 20.
After creating the checkpoint, you can use tar, cp, xcopy.exe, or any other method to copy the checkpoint file and the depot directories to the new machine. (You won't need to copy the db.* files, because they will be recreated from the checkpoint you took.)
Depot subdirectories can contain both text and binary files. The text files (in RCS format, ending with ",v") and binary files (directories of individual binary files, each directory ending with ",d") will need to be transferred differently in order to translate the line endings on the text files while leaving the binary files unchanged.
Contact Perforce Technical Support for assistance when migrating a Perforce server from NT to UNIX or vice-versa.
If you are a licensed Perforce customer, you will also need to get a new license file to reflect the new IP address. Contact Perforce technical support to obtain an updated license.
When using local depots, the user's Perforce client program communicates with the Perforce server specified by the user's P4PORT environment variable or equivalent setting.
When using remote depots, the user's Perforce client uses its default Perforce server as a proxy client to a second, remote, Perforce server. Because of this proxy behavior, the client doesn't need to know where the files are actually stored, and doesn't need direct access to the remote Perforce server. The following diagram illustrates how remote depots use a user's default Perforce server as a proxy.
The use of depots on remote servers ("remote depots") is limited to read-only operations; a Perforce client may not add, edit, integrate into, or delete files that reside in depots on other servers. Depots sharing the same Perforce server as the client ("local depots") are not subject to this limitation.
This is not, in fact, the case. Perforce is designed to cope with the latencies of large networks, it inherently supports users with client workspaces at remote sites. A single Perforce installation is ready, out of the box, to support a shared development project, regardless of the geographic distribution of its contributors.
Remote depots are designed to support shared code, not shared development. They enable independent organizations with their own Perforce installations to view files and integrate changes from depots in other installations. Remote depots are not a generalized solution for load-balancing or network access problems.
If, however, you're regularly importing works from other organizations as part of your own organization's body of software, you may wish to consider using Perforce's remote depot features. This is what remote depots were designed for: facilitating the sharing of code, not development, across organizations.
To define the default depot, run p4 depot with the default depotname of depot. The p4 depot command will bring up the following form:
When p4 depot depot is invoked, the form is filled in with values representing the state of the default depot. Its name is depot. It resides in the local Perforce server namespace; so its type is local, (as opposed to remote). The Map: field indicates the location of the depot subdirectory relative to the root directory of the Perforce server; in this default case, the depot called depot starts in the depot subdirectory directly underneath the server root. (i.e. $P4ROOT/depot)
Now that you've defined the default depot, you can define other depots as you require.
Although you can set the Map: field to point to a depot directory other than one matching the depot name, there is rarely any advantage to be had by doing so, and it can make life confusing should you (as an administrator) ever need to work with the directories in the server root.
Lisa is working on a GUI porting project. She and Ed are using different Perforce servers; his is on host
pine, and it's listening on port 1818. Lisa wants to grab Ed's GUI routines for her own use; she knows that
Ed's color routine files are located on his Perforce server's single depot under the subdirectory graphics/GUI
.
Lisa's first step towards accessing Ed's files is to create a new depot. She'll call this depot gui; she'd type p4
depot GUI and fill in the form as follows:
This creates a remote depot called gui on Lisa's Perforce server; this depot (gui) maps to Ed's depot's
namespace under its graphics/gui subdirectory.
If you are unfamiliar with client views and mappings, please consult the Perforce User's Guide for general information about how Perforce mappings work.
To limit or eliminate remote access to a particular server, use p4 protect to set permissions for user remote on that server. For example, to eliminate remote access to all files in all depots on a particular server, set the following permission on that server:
read user remote * -//...
Since remote depots can only be used for read access, it is not necessary to remove write or super access.
The Perforce User's Guide contains detailed information of interest to users who will be working with more than one depot.
Perforce 2000.1 System Administrator's Guide (2000.1.sa.3) | ||
<< Previous Chapter Supporting Perforce: Backup and Recovery |
Table of Contents Index Perforce on the Web |
Next Chapter >> Administering Perforce: Protections |