01: /**
02: * $Id: LinuxTasks.java,v 1.6 2006/10/23 01:51:10 pr150268 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: public class LinuxTasks extends UnixTasks {
26:
27: private static String fs = System.getProperty("file.separator");
28: private static Logger logger = PortalLogger
29: .getLogger(LinuxTasks.class);
30:
31: public LinuxTasks(PSConfigContext globalContext) {
32: super (globalContext);
33: }
34:
35: public void createSymbolicLink(String source, String target) {
36: String cmd = "/bin/ln";
37: String[] args = { "-fs", source, target };
38: try {
39: execUtil.exec(cmd, args);
40: } catch (Exception e) {
41: logger.log(Level.SEVERE, "PSFB_CSPFUOS0001", e);
42: }
43: }
44:
45: public void removeSymbolicLink(String target) {
46: String cmd = "/bin/unlink";
47: String[] args = { target };
48: try {
49: execUtil.exec(cmd, args);
50: } catch (Exception e) {
51: if (logger.isLoggable(Level.SEVERE)) {
52: LogRecord rec = new LogRecord(Level.SEVERE,
53: "PSFB_CSPFUOS0002");
54: rec.setLoggerName(logger.getName());
55: rec.setParameters(new Object[] { target });
56: rec.setThrown(e);
57: logger.log(rec);
58: }
59:
60: }
61: }
62:
63: public void addNetFilePAM() {
64: String pam = fs + "etc" + fs + "pam.d" + fs + "netfile";
65: File pamFile = new File(pam);
66: if (pamFile.exists()) {
67: logger.log(Level.INFO, "PSFB_CSPFUOS0003");
68: } else {
69: try {
70: pamFile.createNewFile();
71: FileWriter fw = new FileWriter(pamFile);
72: fw
73: .write("auth required //lib//security//pam_unix.so\n");
74: fw
75: .write("account required //lib//security//pam_unix.so\n");
76: fw
77: .write("password required //lib//security//pam_unix.so\n");
78: fw
79: .write("session required //lib//security//pam_unix.so\n");
80: fw.close();
81: } catch (Exception e) {
82: logger.log(Level.SEVERE, "PSFB_CSPFUOS0004");
83: }
84: }
85: }
86:
87: }
|