~jamesodhunt/ubuntu/trusty/upstart/1.11

« back to all changes in this revision

Viewing changes to init/job_class.c

  • Committer: James Hunt
  • Date: 2013-11-14 17:41:01 UTC
  • mfrom: (1436.2.4)
  • Revision ID: james.hunt@ubuntu.com-20131114174101-t5q1qgkk5nd4c15p
New upstream release (LP: #1238078, #1221466, #1240686, #1203595, #1235649).

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
static char **job_environ = NULL;
98
98
 
99
99
/**
 
100
 * initial_umask:
 
101
 *
 
102
 * Value of umask at startup.
 
103
 **/
 
104
mode_t initial_umask;
 
105
 
 
106
/**
100
107
 * job_class_init:
101
108
 *
102
109
 * Initialise the job classes hash table.
138
145
void
139
146
job_class_environment_reset (void)
140
147
{
141
 
        if (job_environ)
 
148
        job_class_environment_clear ();
 
149
        job_class_environment_init ();
 
150
}
 
151
 
 
152
/**
 
153
 * job_class_environment_clear:
 
154
 *
 
155
 * Clear the environment table.
 
156
 **/
 
157
void
 
158
job_class_environment_clear (void)
 
159
{
 
160
        if (job_environ) {
142
161
                nih_free (job_environ);
143
 
 
144
 
        job_environ = NULL;
145
 
 
146
 
        job_class_environment_init ();
 
162
                job_environ = NULL;
 
163
        }
147
164
}
148
165
 
149
166
/**
353
370
 
354
371
        class->console = default_console >= 0 ? default_console : CONSOLE_LOG;
355
372
 
356
 
        class->umask = JOB_DEFAULT_UMASK;
 
373
        class->umask = (user_mode && ! no_inherit_env) ? initial_umask : JOB_DEFAULT_UMASK;
357
374
        class->nice = JOB_NICE_INVALID;
358
375
        class->oom_score_adj = JOB_DEFAULT_OOM_SCORE_ADJ;
359
376
 
1802
1819
        return 0;
1803
1820
}
1804
1821
 
 
1822
/**
 
1823
 * job_class_serialise_job_environ:
 
1824
 *
 
1825
 * Serialise the global job environment table.
 
1826
 *
 
1827
 * Returns: JSON-serialised global job environment table, or NULL on error.
 
1828
 **/
 
1829
json_object *
 
1830
job_class_serialise_job_environ (void)
 
1831
{
 
1832
        json_object  *json;
 
1833
 
 
1834
        job_class_environment_init ();
 
1835
 
 
1836
        json = state_serialise_str_array (job_environ);
 
1837
        if (! json)
 
1838
                goto error;
 
1839
 
 
1840
        return json;
 
1841
 
 
1842
error:
 
1843
        json_object_put (json);
 
1844
        return NULL;
 
1845
}
 
1846
 
 
1847
/**
 
1848
 * job_class_deserialise_job_environ
 
1849
 * @json: JSON-serialised global job environment table to deserialise.
 
1850
 *
 
1851
 * Create the global job environment table from provided JSON.
 
1852
 *
 
1853
 * Returns: 0 on success, < 0 on error.
 
1854
 **/
 
1855
int
 
1856
job_class_deserialise_job_environ (json_object *json)
 
1857
{
 
1858
        nih_assert (json);
 
1859
 
 
1860
        nih_assert (! job_environ);
 
1861
 
 
1862
        if (! state_check_json_type (json, array))
 
1863
                goto error;
 
1864
 
 
1865
        if (! state_deserialise_str_array (NULL, json, &job_environ))
 
1866
                goto error;
 
1867
 
 
1868
        return 0;
 
1869
 
 
1870
error:
 
1871
        return -1;
 
1872
}
 
1873
 
1805
1874
 
1806
1875
/**
1807
1876
 * job_class_serialise: