01: /**
02: * $Id: HpuxTasks.java,v 1.2 2007/01/26 03:48:35 portalbld Exp $
03: * Copyright 2004 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.fabric.util.os;
14:
15: import com.sun.portal.admin.common.context.PSConfigContext;
16:
17: import java.util.logging.Logger;
18: import java.util.logging.Level;
19: import java.util.logging.LogRecord;
20: import java.io.File;
21: import java.io.FileWriter;
22:
23: import com.sun.portal.log.common.PortalLogger;
24:
25: import com.sun.portal.util.Platform;
26:
27: public class HpuxTasks extends UnixTasks {
28:
29: private static String fs = Platform.fs;
30: private static Logger logger = PortalLogger
31: .getLogger(HpuxTasks.class);
32:
33: public HpuxTasks(PSConfigContext globalContext) {
34: super (globalContext);
35: }
36:
37: public void createSymbolicLink(String source, String target) {
38: String cmd = "/bin/ln";
39: String[] args = { "-fs", source, target };
40: try {
41: execUtil.exec(cmd, args);
42: } catch (Exception e) {
43: logger.log(Level.SEVERE, "PSFB_CSPFUOS0001", e);
44: }
45: }
46:
47: public void removeSymbolicLink(String target) {
48: String cmd = "/bin/unlink";
49: String[] args = { target };
50: try {
51: execUtil.exec(cmd, args);
52: } catch (Exception e) {
53: if (logger.isLoggable(Level.SEVERE)) {
54: LogRecord rec = new LogRecord(Level.SEVERE,
55: "PSFB_CSPFUOS0002");
56: rec.setLoggerName(logger.getName());
57: rec.setParameters(new Object[] { target });
58: rec.setThrown(e);
59: logger.log(rec);
60: }
61:
62: }
63: }
64:
65: public void addNetFilePAM() {
66: String pam = fs + "etc" + fs + "pam.d" + fs + "netfile";
67: File pamFile = new File(pam);
68: if (pamFile.exists()) {
69: logger.log(Level.INFO, "PSFB_CSPFUOS0003");
70: } else {
71: try {
72: pamFile.createNewFile();
73: FileWriter fw = new FileWriter(pamFile);
74: fw
75: .write("auth required //lib//security//pam_unix.sl");
76: fw
77: .write("account required //lib//security//pam_unix.sl");
78: fw
79: .write("password required //lib//security//pam_unix.sl");
80: fw
81: .write("session required //lib//security//pam_unix.sl");
82: fw.close();
83: } catch (Exception e) {
84: logger.log(Level.SEVERE, "PSFB_CSPFUOS0004");
85: }
86: }
87: }
88:
89: }
|